All submissions for this problem are available.
The C Plus International (CPI) and C Plus International [Mathematicians] (CPI M) have always been against each other. CPI this time around wants to show the people that even they have high maths skills like CPI M. The people of the country try to test this new skill of the party with a simple problem.
The problem is as follows : Given two numbers N and P the problem asks to find the last digit of NP. Even this problem is too tough for CPI to handle. So they hire you to write a program to solve this problem.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows
each test case contains two space separated Integers N and P
For each test case, output a single line containing a single Integer , the
last Digit of NP
- 1 <= T <= 105
- 0 <= N,P <= 1018
Input: 4 2 3 2 4 3 3 3 4 Output: 8 6 7 1
In the first test case, 23 is 8, so the last digit is 8. In the second case 24 is 16. But we want only the last digit, so answer is 6.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, GO|
Fetching successful submissions