import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { String s = sc.next(); int flg = 0; int keizoku = 0; int kuriage = 0; int hatsu = 0; String ans = ""; for(int j = s.length() - 1; j >= 0; j--) { String str = String.valueOf(s.charAt(j)); if(flg == 0) { try{ int d = Integer.parseInt(str); keizoku = 1; if(hatsu == 0) { hatsu = 1; if(d + 1 < 10) { ans = (d + 1) + ans; flg = 1; } else { ans = "0" + ans; kuriage = 1; } } else { if(d + kuriage < 10) { ans = (d + kuriage) + ans; flg = 1; } else { ans = "0" + ans; kuriage = 1; } } } catch(NumberFormatException e) { if(keizoku == 1 && kuriage > 0) { ans = "1" + ans; } ans = str + ans; if(keizoku == 1) flg = 1; } } else { ans = str + ans; } } System.out.println(ans); } } }