#n: #1+3+5+7+..+[1+2*(n-1)] #1+3+5+7+...+[2n-1]=[1+2n-1]*n/2=n**2 n=int(input()) for i in range(n): a=int(input()) print(a**2%10000)