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 pow2(ex,k):
	a=2
	re=1
	while (ex>0):
		if (ex%2==1):
			re=re*a;
			re=re%k;
		a=a*a;
		a=a%k;
		ex=ex/2;
	return re;

a=[1,1,2,6,4]
def getlastdigit(n):
	if (n/5==0):
		return a[n]
	else:
		return (getlastdigit(n/5)*pow2(n/5,10)*getlastdigit(n%5))%10

t=input()
raw_input()
while t:
	t-=1
	n=input()
	print getlastdigit(n)