SP5699 LASTDIG2 - The last digit re-visited

Description

Pappu was doing the work of his math class about three days but he is tired of make operations a lot and he should deliver his task tomorrow. His math’s teacher gives two numbers a and b. The problem consist in find the last digit of the potency of base a and index b. Help Pappu with his problem. You are given two integer numbers: the base a (number of digits d, such that 1

Input Format

The first line of input contains an integer t, the number of test cases (t

Output Format

For each test case output an integer per line representing the result.