import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(increment(sc.nextLine())).append("\n"); } System.out.print(sb); } static String increment(String org) { char[] arr = org.toCharArray(); boolean has9 = false; int last9 = 0; for (int i = arr.length - 1; i >= 0; i--) { if (arr[i] == '9') { if (!has9) { last9 = i; } has9 = true; } else if (arr[i] >= '0' && arr[i] <= '8') { arr[i] = (char)(arr[i] + 1); if (has9) { for (int j = i + 1; j <= last9; j++) { arr[j] = '0'; } } has9 = false; break; } else { if (has9) { arr[i + 1] = '1'; for (int j = i + 2; j <= last9; j++) { arr[j] = '0'; } break; } } } if (has9) { StringBuilder sb = new StringBuilder(new String(arr)); sb.insert(last9, '0'); return sb.toString(); } else { return new String(arr); } } }