for _ in range(int(input())): L = list(map(int, input())) while len(L) > 1: L2 = [] for i in range(len(L)-1): X = L[i] + L[i+1] L2 += [[X, X//10 + X%10][X > 9]] L = L2 print(*L)