Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Hello Choto Bondhu!

By Shahwat_Has9 · Limits 1s, 512 MB

Let's play a game. I will give you a number nn. You will have to tell me n2n^2. Okay, it may seem difficult for you to calculate this huge number. So tell me the last digit of n2n^2. In other words: n2mod10n^2 \mod 10.

Input

The first line will contain TT (1T1001 ≤ T ≤ 100), which indicates test cases.

Next TT lines will each contain a number nn (1n101000001 ≤ n ≤ 10^{100000}).

Output

For each cases, print n2mod10n^2 \mod 10.

Sample

InputOutput
6
1
2
3
4
5
6
1
4
9
6
5
6

When n=1n = 1, ans=(nn)mod10=1mod10=1ans = (n * n) \mod 10 = 1 \mod 10 = 1.

When n=2n = 2, ans=(nn)mod10=4mod10=4ans = (n * n) \mod 10 = 4 \mod 10 = 4.

When n=3n = 3, ans=(nn)mod10=9mod10=9ans = (n * n) \mod 10 = 9 \mod 10 = 9.

When n=4n = 4, ans=(nn)mod10=16mod10=6ans = (n * n) \mod 10 = 16 \mod 10 = 6.

When n=5n = 5, ans=(nn)mod10=25mod10=5ans = (n * n) \mod 10 = 25 \mod 10 = 5.

When n=6n = 6, ans=(nn)mod10=36mod10=6ans = (n * n) \mod 10 = 36 \mod 10 = 6.


Discussion

Toph uses cookies. By continuing you agree to our Cookie Policy.