for _ in[0]*int(input()): s=input() while len(s)>1: k=zip(s[:],s[1:]);s="" for i,j in k:t=int(i)+int(j);s+=str(t%10+t//10) print(s)