a=int(input()) d=[] for i in range(a): b=int(input()) if b!=0: c=b*b d.append(c) else: d.append(0) b=c=0 for i in d: print(i%10000)