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) { int? left = null, right = null; for (int i = s.Length - 1; i >= 0; i--) { if ('0' <= s[i] && s[i] <= '9' && !right.HasValue) { right = i; } else if(!('0' <= s[i] && s[i] <= '9')&&right.HasValue) { left = i + 1; break; } } if (right.HasValue && !left.HasValue) { left = 0; } if (left == null) return s; string a = s.Remove(left.Value); string c = s.Substring(right.Value + 1); string bb = s.Substring(left.Value, right.Value - left.Value + 1); string b; if (s[left.Value] == '0') { b = (int.Parse(bb) + 1).ToString().PadLeft(right.Value - left.Value + 1,'0'); } else { b = (int.Parse(bb) + 1).ToString(); } return a + b + c; } 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()); } }