#include #include #include using namespace std; #define N 10000005 int n,m,k,l,t,T; int a[N],p[10]; char st[N]; int main(){ scanf("%d",&T); while(T--){ memset(p,0,sizeof(p)); memset(a,0,sizeof(a)); scanf("%s",st+1); n=strlen(st+1); for (int i=1;i<=n;i++)p[st[i]-48]++; for (int i=1;i<=9;i++)if(p[i]){k=i;break;} p[k]--; t=0; for (int i=0;i<=9;i++) while(p[i]--)a[++t]=i; if(a[t]==0){puts("Uncertain");continue;} a[1]+=k; for (int i=1;i<=t;i++){ a[i+1]+=a[i]/10; a[i]%=10; } if(a[t+1])t++; for (int i=t;i;i--)printf("%d",a[i]); puts(""); } }