#include #include #include #include #include #include #include #include #include #include using namespace std; //#pragma comment(linker, "/STACK:1024000000,1024000000") #define FIN freopen("input.txt","r",stdin) #define FOUT freopen("output.txt","w",stdout) #define fst first #define snd second #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef __int64 LL; //typedef long long LL; typedef unsigned int uint; typedef pair PII; typedef pair PLL; const int INF = 0x3f3f3f3f; const double eps = 1e-6; const int MAXN = 10000000 + 5; const int MAXM = 600 + 5; int T; char s[MAXN]; int cnt[10]; stack S1, S2; int main() { #ifndef ONLINE_JUDGE FIN; #endif // ONLINE_JUDGE scanf("%d", &T); while (T --) { scanf("%s", s); int len = strlen(s); memset(cnt, 0, sizeof(cnt)); for (int i = 0; i < len; i++) { cnt[s[i] - '0'] ++; } if (cnt[0] >= len - 1) { puts("Uncertain"); continue; } int a, b, c; for (int i = 1; i <= 9; i++) { if (cnt[i] > 0) { b = i; cnt[i] --; break; } } for (int i = 9; i >= 0; i--) { if (cnt[i] > 0) S1.push(i); } while (!S1.empty()) { a = S1.top(); cnt[a] --; if (cnt[a] == 0) S1.pop(); c = a + b; if (c >= 10) { b = 1; c -= 10; } else { b = 0; } S2.push(c); } if (b == 1) printf("%d", b); while (!S2.empty()) { c = S2.top(); S2.pop(); printf("%d", c); } puts(""); } return 0; }