using System; using System.Collections.Generic; using System.IO; using System.Linq; public class YukiCoder { public static void Solve() { var T = MyConsole.Int(); while (T-- > 0) { string ANS = MyConsole.String(); while (ANS.Length > 1) { var len = ANS.Length; string math = ""; for (int pos = 0 ; pos < len - 1 ; pos++) { int tmp = int.Parse( ANS[pos].ToString() ) + int.Parse( ANS[pos + 1].ToString() ); if (tmp >= 10) { math += tmp / 10 + ( tmp - 10 ); } else { math += tmp; } } ANS = math; } MyConsole.wLine( ANS.ToString() ); } } public static void Main() { MyConsole.Read(); Solve(); MyConsole.Finish(); } } public static class MyConsole { private static List ReadedLine = new List(); private static char[] buf = new char[1024]; private static int i; public static void Read() { string sr = Console.In.ReadToEnd(); ReadedLine = sr.Split( new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries ).ToList(); Console.SetOut( new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false } ); } public static string String() { return ReadedLine[i++]; } public static string[] StringSplit() { return ReadedLine[i++].Split( new[] { ' ' } ); } public static int Int() { return int.Parse( ReadedLine[i++] ); } public static int[] IntSplit() { string[] strs = StringSplit(); int[] ret = new int[strs.Length]; for (int i = 0 ; i < strs.Length ; i++) { ret[i] = int.Parse( strs[i] ); } return ret; } public static long Long() { return long.Parse( ReadedLine[i++] ); } public static double Double() { return double.Parse( ReadedLine[i++] ); } public static void wLine( string output = null ) { Console.WriteLine( output ); } public static void Finish() { Console.Out.Flush(); } }