LSTDGT - Last Digit of Power

Given two numbers a and b. Find the last digit of a^b. (a to the power b).

Input

There will be t (1 <= t <= 10) test cases. In each case there will be two number a (1 <= a <= 10^100000) and b (1 <= b <= 10^100000) separated by a space.

Output

Print the last digit of a^b in a single line.

Example

Input:
2
3 10
6 2

Output:
9
6

Added by:Jamil Siam
Date:2017-05-31
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2017-10-06 07:19:52
Just remove unneccessary blank lines to get your code under source limit.
2017-06-01 21:28:27
well quite easy one...
2017-06-01 19:39:55 Francky
To be moved to tutorial very soon !
2017-06-01 16:46:02 [Lakshman]
@Jamil Siam: Changing time limit is not an good idea after you publish the Problem. We have all ready many problem slimier to this.
2017-06-01 16:32:08 Jamil Siam
@all: TL has been updated. Please try again.

Last edit: 2017-06-01 16:33:46
2017-06-01 09:19:29 [Lakshman]
Please move this to tutorials ASAP.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.