import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); String line = sc.nextLine(); String s1 = ""; String s2 = ""; for(int i = 0; i < T; i++) { String s = sc.nextLine(); char[] ss = s.toCharArray(); int p = 0; int increment = 1; int k = 0; int ind = 0; for(int j = s.length() - 1; j >= 0; j--) { String str = String.valueOf(s.charAt(j)); int t = -1; try { t = Integer.parseInt(str); } catch(NumberFormatException e) { } if(t == -1) { if(p == 0) { } else { if(increment == 1) { k = 1; ind = j + 1; break; } } } else { p = 1; if(increment == 1) { if(t == 9) { ss[j] = "0".charAt(0); } else { ss[j] = (String.valueOf(t + 1)).charAt(0); break; } } } } if(k == 0) { System.out.println(new String(ss)); } else { String sa = new String(ss); s1 = sa.substring(0, ind); s2 = sa.substring(ind, s.length()); System.out.println(s1 + "1" + s2); } } } }