var sum:array[0..9] of longint; t,l,i,j,r,p,k,o:longint; x:char; ans:array[1..10000007] of longint; begin readln(t); for l:=1 to t do begin fillchar(ans,sizeof(ans),0); fillchar(sum,sizeof(sum),0); while not(eoln) do begin read(x); inc(sum[ord(x)-48]); end; readln; r:=1; while (r<=9) and (sum[r]=0) do inc(r); p:=0; for i:=1 to 9 do p:=p+sum[i]; if (p=0) or (p=1) then writeln('Uncertain') else begin dec(sum[r]); j:=1; for i:=9 downto 0 do for k:=1 to sum[i] do begin ans[j]:=i; inc(j); end; dec(j); ans[j]:=ans[j]+r; o:=0; for i:=j downto 1 do begin ans[i]:=ans[i]+o; o:=ans[i] div 10; ans[i]:=ans[i] mod 10; end; if (o<>0) then write(o); for i:=1 to j do write(ans[i]); writeln; end; end; end.