LASTDIG2  The last digit revisited
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 <= d <= 1000) and the index b (0 <= b <= 922*10^15). You have to find the last digit of a^b.
Input
The first line of input contains an integer t, the number of test cases (t <= 30). t test cases follow. For each test case will appear a and b separated by space.
Output
For each test case output an integer per line representing the result.
Example
Input: 3 3 10 6 2 150 53 Output: 9 6 0
Source limit is 700 Bytes.
hide comments
th3ghost:
20190729 19:36:39
just use python for this


aj_254:
20190523 21:58:17
one liner in python print(pow(a,b,10)) 

r210397:
20180628 10:26:53
very easy ac at last


dennislo:
20180613 23:24:11
Test cases are very weak:


s_a_k_s_h_a_m:
20180612 15:04:16
@srijan123j it will be 0


shashankpathak:
20180503 08:07:40
source limit 700 bytes i am not able to space optimize my code ! 

nsh__:
20180221 20:08:06
AC in One GO !!! 

Michael Kharitonov:
20180107 10:56:46
@diptark_bose: EOL was converted to CRLF, use "Choose file" to prevent this from happening. Last edit: 20180107 10:57:07 

diptark_bose:
20180105 06:00:44
My source code is an exact 697 characters (which is <700 bytes). Still getting "Exceeding 700 bytes error"!! 

bayulaxana:
20180101 06:50:39
don't forget if b can be 0..

Added by:  Hari 
Date:  20091227 
Time limit:  1s 
Source limit:  700B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS OBJC PERL6 SQLITE VB.NET 
Resource:  harrydcoder 