using System; namespace Yukicoder { public class Program { public static void Main() { int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string num = Console.ReadLine(); Solve(num); } } private static void Solve(string num) { string tmp = num; string ans = ""; int len = tmp.Length; while (len > 1) { for (int i = 1; i < len; i++) { int x = GetInt(tmp[i], tmp[i - 1]); string str = x.ToString(); ans += x > 9 ? GetInt(str[0],str[1]).ToString() : str; } tmp = ans; ans = ""; len--; } Console.WriteLine(tmp); } private static int GetInt(char v1, char v2) { return (v1 - '0') + (v2 - '0'); } } }