LSTDGT - Last Digit of Power

no tags 

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

hide comments
g_o_d: 2017-10-06 07:19:52

Just remove unneccessary blank lines to get your code under source limit.

ssunitk: 2017-06-01 21:28:27

well quite easy one...

Francky: 2017-06-01 19:39:55

To be moved to tutorial very soon !

[Lakshman]: 2017-06-01 16:46:02

@Jamil Siam: Changing time limit is not an good idea after you publish the Problem. We have all ready many problem slimier to this.

Jamil Siam: 2017-06-01 16:32:08

@all: TL has been updated. Please try again.

Last edit: 2017-06-01 16:33:46
[Lakshman]: 2017-06-01 09:19:29

Please move this to tutorials ASAP.


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