import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int T = sc.nextInt(); for(int tt = 0; tt < T; tt++){ final char[] inputs = sc.next().toCharArray(); int[] curr = new int[inputs.length]; for(int i = 0; i < inputs.length; i++){ curr[i] = Character.getNumericValue(inputs[i]); } for(int length = curr.length; length >= 1; length--){ for(int i = 0; i < length - 1; i++){ curr[i] = (curr[i] + curr[i + 1]) % 10 + (curr[i] + curr[i + 1]) / 10; } } System.out.println(curr[0]); } } }