Problem G
Power et al.
Input: Standard Input
Output: Standard Output
Finding the exponent of any number can be very troublesome as it grows exponentially J. But in this problem you will have to do a very simple task. Given two non-negative numbers m and n, you will have to find the last digit of mn in decimal number system.
Input
The input file contains less than 100000 lines. Each line contains two integers m and n (Less than 10^101). Input is terminated by a line containing two zeroes. This line should not be processed.
Output
For each set of input you must produce one line of output which contains a single digit. This digit is the last digit of mn.
2 2 2 5 0 0 |
4 2 |
Problemsetter: Shahriar Manzoor