#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back #define scan(x) scanf("%d",&x) typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const ll mod = 1e9 + 7; const int MAXN = 10000010; const int LOG = 20; int T; char s[10000010]; int num[10]; int main(){ scanf("%d",&T); while(T--){ memset(num,0,sizeof(num)); scanf("%s",s + 1); int cnt = 0,tmin = INF; for(int i = 1; s[i]; ++i){ int v = s[i] - '0'; num[v]++; if(s[i] > '0'){ cnt++; tmin = min(tmin,v); } } if(cnt < 2){ printf("Uncertain\n"); continue; } num[tmin]--; int c = 0; for(int i = 9; i >= 0; --i){ if(num[i] == 0) continue; while(num[i]--){ s[c++] = i + '0'; } } s[c] = '\0'; s[c - 1] += tmin; int g = 0; for(int i = c - 1; i >= 0; --i){ int v = s[i] - '0' + g; g = v / 10; s[i] = '0' + v % 10; if(g == 0) break; } if(g) printf("1"); printf("%s\n",s); } return 0; }