Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

Problem hidden on 2014-04-23 12:48:12 by Francky

WPC5B - Crypto

no tags 

The coordinators in galaxy H3 are keen on winning the Galactic Wars, as always. They have decided to take advice from their ancestors who have relocated to galaxy H1, through a secure computer connection. However, this would be considered a violation of the Model Code of Conduct, and hence the channel needs to be completely secure, so that the Inter-Galactic Police cannot intercept their communication

H3 citizens also know the ancient magical technique of finding the first (least-significant) digit of a^b for any integers a and b as quickly as snap. Pande and Pande have recently collaborated, for the first time ever, and produced a brilliant encryption verification algorithm using this fact. The coordinators would pick two numbers a, b and transmit it. The ancestors in H1 would calculate a^b and return it. If the correct a^b was returned, it would mean that the targetted people were sitting at the other end.

As a Martian intern at the Inter-Galactic Police, you intend to become famous by cracking this connection. Can you find the ancient technique?

 

Input: 
First line contains a single integer T, denoting the number of Test Cases.
T lines containing space separated integers: a and b, denoting the test case you have to crack.
Warning: Fast IO may be needed in some languages.
Output:
Output T lines each containing the least significant digit of a^b, needed to break the encryption system.
Note: 0^0 = 1
Constraints:
1 <= T <= 1000000
1 <= a,b <= 10^18
Time Limit: 1 second
Example:
Input:
1
2 3
Output:
8
Explanation: 2^3 = 8.

Input

First line contains a single integer T, denoting the number of Test Cases.

T lines containing space separated integers: a and b, denoting the test case you have to crack.

 

Warning: Fast IO may be needed in some languages.

 

Output:

Output T lines each containing the least significant digit of a^b, needed to break the encryption system.

Note: 0^0 = 1

 

Constraints:

1 <= T <= 1000000

1 <= a <= 10^18

0<= b <= 10^18

 

Time Limit: 1 second

 

Example:

Input:

1

2 3

 

Output:

8

 

Explanation: 2^3 = 8.

 


hide comments
Francky: 2014-04-23 12:47:31

This problem is too near from LASTDIG, no need to make duplicates. Moved to tutorial, and hidden. There's too LASTDIG2...

sankar: 2014-04-23 09:23:07

Here is one test case
1
100000000000000876 1000000000000728

Answer is 6

sankar: 2014-04-23 09:20:54

@Keyser Soze, We have to find the last digit of a^b

Hamim Raavi: 2014-04-20 07:46:43

my 100th classical

Nishanth Vijayan: 2014-04-19 20:15:44

what exactly are we supposed to find? a^b or lastdigit of a^b?

Shuvojit Saha: 2014-04-13 20:43:56

which algorithm i use to solve this problem

Atul Aditya: 2014-04-02 14:39:33

@triveni could u check my sol...im getting wa..even though its working for all cases submission id.. 11376641

Kanish_The_Vista: 2014-04-01 20:24:18

Last edit: 2014-04-02 18:15:25
[Lakshman]: 2014-04-01 18:11:18

@Triveni Mahatha can you check my last submission getting WA.


Added by:triveni
Date:2014-03-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:ACA judge IITK, WPC5