#P1524. A magical problem of number theory

A magical problem of number theory

题目描述

Given a positive integer NN, you should output the most right digit of NNN^N.

输入格式

The input contains several test cases. The first line of the input is a single integer TT which is the number of test cases. TT test cases follow. Each test case contains a single positive integer

NN(1<=N<=1,000,000,0001<=N<=1,000,000,000).

输出格式

For each test case, you should output the rightmost digit of NNN^N.

样例

2 
3 
4
7 
6 

提示

In the first case, 333^3 = 27, so the rightmost digit is 7.

In the second case, 444^4 = 256, so the rightmost digit is 6.

原题HDU - 1061

By ZenF1sh of QLU