import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int T = scan.nextInt(); String []S = new String[T]; for(int i = 0; i < T; i++) { S[i] = scan.next(); } scan.close(); for(int i = 0; i < T; i++) { solve(S[i]); } } public static void solve(String s) { int l = s.length(); if(l == 1) { System.out.println(s); return ; }else { StringBuilder sb = new StringBuilder(); for(int i = 0; i < l - 1; i++) { int s1 = Integer.parseInt(s.substring(i, i + 1)); int s2 = Integer.parseInt(s.substring(i + 1, i + 2)); int sum = s1 + s2; if(sum >= 10) { int k1 = sum / 10; int k2 = sum - 10; int sum2 = k1 + k2; sb.append(Integer.toString(sum2)); }else { sb.append(Integer.toString(sum)); } } //System.out.println(sb.length()); solve(sb.toString()); } } }