using System; using System.Collections.Generic; namespace _432 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string s = Console.ReadLine(); List list = new List(); for (int j = 0; j < s.Length; j++) list.Add(int.Parse(s[j].ToString())); while (list.Count > 1) { List result = new List(); for (int j = 0; j < list.Count - 1; j++) { int a = list[j] + list[j + 1]; result.Add(a >= 10 ? 1 + (a % 10) : a); } list = result; } Console.WriteLine(list[0]); } } } }