import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int[][] arr = new int[t][]; for (int i = 0; i < t; i++) { String line = sc.next(); arr[i] = new int[line.length()]; for (int j = 0; j < line.length(); j++) { arr[i][j] = line.charAt(j) - '0'; } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { for (int j = 0; j < arr[i].length - 1; j++) { for (int k = 0; k < arr[i].length - j - 1; k++) { int x = arr[i][k] + arr[i][k + 1]; arr[i][k] = x / 10 + x % 10; } } sb.append(arr[i][0]).append("\n"); } System.out.print(sb); } }