2019 NA Regionals Practice Contest 7

Start

2019-11-02 09:00 AKDT

2019 NA Regionals Practice Contest 7

End

2019-11-02 14:00 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -816 days 15:43:23

Time elapsed

5:00:00

Time remaining

0:00:00

Problem G
Last Factorial Digit

/problems/lastfactorialdigit/file/statement/en/img-0001.jpg
Factorials on the complex plane, by Dmitrii Kouznetsov

The factorial of $N$, written as $N!$, is defined as the product of all the integers from $1$ to $N$. For example, $3! = 1 \times 2 \times 3 = 6$.

This number can be very large, so instead of computing the entire product, just compute the last digit of $N!$ (when $N!$ is written in base $10$).

Input

The first line of input contains a positive integer $1 \leq T \leq 10$, the number of test cases. Each of the next $T$ lines contains a single positive integer $N$. $N$ is at most $10$.

Output

For each value of $N$, print the last digit of $N!$.

Sample Input 1 Sample Output 1
3
1
2
3
1
2
6
Sample Input 2 Sample Output 2
2
5
2
0
2