using System.Text; using System; public class Hello { static void Main() { var T = int.Parse(Console.ReadLine().Trim()); while (T-- > 0) { var s = Console.ReadLine().Trim(); getAns(s); } } static string plus1(string s) { if (s == "") return ""; var sL = s.Length; var sa = s.ToCharArray(); var kup = false; var up = false; var w = sa[sL - 1] - '0' + 1; if (w <= 9) return s.Substring(0, sL - 1) + w.ToString(); else { if (sL == 1) kup = true; up = true; sa[sL - 1] = '0'; var p = sL - 2; while (p >= 0) { w = up ? sa[p] - '0' + 1 : sa[p] - '0'; if (w <= 9) { sa[p] = w.ToString()[0]; break; } else { sa[p] = '0'; if (p == 0) kup = true; } p--; } var w2 = kup ? "1" + new string(sa) : new string(sa); return w2; } } static bool checkNum(char t) { var t2 = t - '0'; return t2 >= 0 && t2 <= 9; } static void getAns(string s) { var sL = s.Length; var p = sL - 1; var ep = -1; while (p >= 0) { if (checkNum(s[p])) { ep = p; p--; break; } p--; } var sp = ep; while (p >= 0) { if (checkNum(s[p])) { sp = p; } else break; p--; } if (sp == -1) Console.WriteLine(s); else { var w = s.Substring(sp, ep - sp + 1); var a2 = plus1(w); string a1; if (sp == 0) a1 = ""; else a1 = s.Substring(0, sp); string a3; if (ep == sL - 1) a3 = ""; else a3 = s.Substring(ep + 1); var sb = new StringBuilder(); sb.Append(a1); sb.Append(a2); sb.Append(a3); Console.WriteLine(sb); } } }