Problem: Atish is very talkative. He just doesn't stop speaking. Unfortunately for those around him, he's also a maths wiz, and befuddles anyone who dares speak to him. Annoyed with this, Souradeep asked him to shut up, to which Atish replied, 
Take a number, x, find its factorial,  remove the zeroes, and find the last digit. Call this the "Atish digit". When you can do this fast enough to satisfy me, I'll shut up. 
Now Souradeep is not a mathlete. So he's come to you for help. Can you help him shut Atish up?

EDIT
Maximum number of test cases - 500,
x<10000

SAMPLE INPUT
5

0
1
24
13
87

SAMPLE OUTPUT
1
1
6
8
4

Solution (in PYTHON):

Solution:
def trailing_zeros(n):
    r = 0
    for i in xrange(5, n+1, 5):
        while i%5 == 0:
            r += 1
            i = i / 5
    return r

def fact(n):
    f2 = f5 = trailing_zeros(n)
    r = 1
    for i in xrange(1,n+1):
        while f2 > 0 and i%2 == 0:
            f2 -= 1
            i /= 2
        while f5 > 0 and i%5 == 0:
            f5 -= 1
            i /= 5
        r = (i*r) % 10
    return r
t=int(raw_input())
raw_input()
for test in xrange(t):
	n=int(raw_input())
	#n=10000000
	print fact(n)