def exec(s_list: list) -> list: """ [3,7,3,5,...] ⇨ [1,1,8,....] """ result_list = [] for k in range(len(s_list)-1): sum = int(s_list[k]) + int(s_list[k+1]) if sum >= 10: sum = sum - 10 + 1 result_list.append(sum) return result_list def main(): n = input() s = [] for i in range(int(n)): s.append(input()) for j in s: s_list = list(j) while len(s_list) > 1: s_list = exec(s_list) print(*s_list,sep = ',')