#include #include #include using namespace std; const int maxn = 10000005; int cmp(int a,int b) { return a>b?a:b; } char s[maxn]; int main() { int t; scanf("%d",&t); while(t--) { memset(s,'0',sizeof(s)); scanf("%s",s); int l=strlen(s),e=-1; if(l==1) printf("Uncertain\n"); else if(l==2) { if(s[0]=='0'||s[1]=='0') printf("Uncertain\n"); else printf("%d\n",s[0]-'0'+s[1]-'0'); } else if(l==3) { int a=0; for(int i=0; i<3; i++) if(s[i]=='0') a++; if(a>=2) printf("Uncertain\n"); else { sort(s,s+3); printf("%d\n",(s[2]-'0')*10+s[1]-'0'+s[0]-'0'); } } else { sort(s,s+l); for(int i=0; i'9') { for(int i=1; i'9') { s[i]-=10; s[i+1]+=1; if(i+1==l) flag=1; } else break; } } if(flag==1) printf("1"); for(int i=l-1; i>0; i--) printf("%c",s[i]); printf("\n"); } else { for(int i=l-1; i>0; i--) if(i!=e) printf("%c",s[i]); printf("%c\n",s[e]); } } } return 0; }