using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; class Program { static void Main() { new Magatro().Solve(); } } class Magatro { private int T; private string Func(string s) { var c = s.ToList(); for (int i = c.Count - 1; i >= 0; i--) { if ('0' <= c[i] && c[i] <= '9') { int j; bool p = true; for (j = i; j >= 0 && p; j--) { if (!('0' <= c[j] && c[j] <= '9')) { break; } if (c[j] == '9') { c[j] = '0'; } else { c[j]++; p = false; break; } } if (p) { c.Insert(j + 1, '1'); } break; } } return new string(c.ToArray()); } private void Scan() { T = int.Parse(Console.ReadLine()); } public void Solve() { Scan(); var sb = new StringBuilder(); for (int i = 0; i < T; i++) { sb.AppendLine(Func(Console.ReadLine())); } Console.WriteLine(sb.ToString()); } }