#P2529. [SHOI2001] 击鼓传花

[SHOI2001] 击鼓传花

Description

HC (Happy Child) and classmates often play a game called "passing the flower" in the classroom. The rule is that the child who gets the flower for the nn-th time must say the last non-zero digit of n!n!. The game proceeds in cycles, and anyone who answers incorrectly has to sing a song as a penalty.

After a few rounds, HC believed that one could simply multiply the previous child's number by nn and then say the last non-zero digit of the resulting number. Unfortunately, when it was HC's turn at n=15n = 15, HC answered 33 and was penalized, while the correct answer should have been 88.

HC does not want this to happen again, so you are asked to write a program that computes the last non-zero digit of n!n!.

Input Format

There are 55 lines of input. The ii-th (1i51 \le i \le 5) line contains an nn (1n101001 \le n \le 10^{100}).

Output Format

Output 55 lines.

The ii-th line should be the last non-zero digit of the factorial of the nn on the ii-th input line.

11
12
13
14
15

8
6
8
2
8

Hint

Translated by ChatGPT 5