import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); StringBuilder ans = new StringBuilder(); for (int i = 0; i < n; i++) { StringBuilder sb = new StringBuilder(sc.nextLine()); boolean nextMode = false; for (int j = sb.length() - 1; j >= 0; j--) { char ch = sb.charAt(j); if (ch >= '0' && ch <= '9') { if (ch == '9') { ch = '0'; sb.setCharAt(j, ch); nextMode = true; } else { ch = (char)(ch + 1); sb.setCharAt(j, ch); nextMode = false; break; } } else { if (nextMode) { sb.insert(j + 1, '1'); nextMode = false; break; } } } if (nextMode) { sb.insert(0, '1'); } ans.append(sb).append("\n"); } System.out.print(ans); } }