Last Digit

0

0 votes
Problem

Given 2 Numbers a and b , find the last digit of a^b.

Input:

The first line of input contains an integer t, the number of test cases (t <= 150). t test cases follow. For each test case will appear a and b separated by space. 0 <= a <= 20 0 <= b <= 10^9

Output:

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

Sample Input
3
3 10
6 2
11 5
Sample Output
9
6
1
Time Limit: 2
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?