using System; using System.Collections.Generic; using System.Text; public class Program { public static void Main() { int T = int.Parse(Console.ReadLine()); for (int i = 0; i < T; i++) { var S = Console.ReadLine(); while (S.Length > 1) { var sb = new StringBuilder(); for (int j = 0; j < S.Length - 1; j++) { int temp = S[j] - '0' + S[j + 1] - '0'; if (temp > 9) { temp = 1 + temp % 10; } sb.Append(temp.ToString()); } S = sb.ToString(); } Console.WriteLine(S); } } }