#include #include #include #include using namespace std; const int maxn = 1e7 + 5; char s[maxn]; int c[maxn]; int main() { int T; scanf("%d", &T); while(T--) { scanf("%s", s); int len = strlen(s); int has = 0; for(int j = 0; j < 10; ++j) c[j] = 0; for(int i = 0; i < len; ++i) { c[s[i] - '0']++; has += s[i] != '0'; } if(has < 2) { puts("Uncertain"); continue; } int cnt = 0; for(int i = 0; i < 10; ++i) { for(int j = 0; j < c[i]; ++j) s[cnt++] = i + '0'; } for(int i = 0; i < len; ++i) { if(s[i] != '0') { swap(s[i], s[0]); break; } } int flag = (s[1] + s[0] - '0' - '0' >= 10); s[len] = '0'; s[1] += s[0] - '0'; if(s[1] > '9') s[1] -= 10; for(int i = 2; i <= len; ++i) { if(flag) { flag = 0; if(++s[i] > '9') { s[i] = '0'; flag = 1; } } else break; } if(s[len] != '0') ++len; reverse(s + 1, s + len); s[len] = 0; puts(s + 1); } return 0; }