#include #include #include using namespace std; #define M 10000010 int a[M], b[M], c[M], v[M]; char s[M]; int main() { //freopen("in.txt", "r", stdin); int T; for (scanf("%d", &T); T--; ) { scanf("%s", s); int n = strlen(s), cnt = 0, m = 0; for (int i = 0; i < n; i++) { int x = s[i] - '0'; if (x) cnt++; v[m++] = x; } sort(v, v + m); reverse(v, v + m); if (cnt <= 1) puts("Uncertain"); else { int na = 0, nb = 0; for (int i = 0; i < cnt - 1; i++) a[na++] = v[i]; for (int j = cnt; j < m; j++) a[na++] = v[j]; b[nb++] = v[cnt - 1]; reverse(a, a + na); int bf = (a[0] + b[0]) / 10; c[0] = (a[0] + b[0]) % 10; for (int i = 1; i < na; i++) { c[i] = (bf + a[i]) % 10; bf = (bf + a[i]) / 10; } if (bf) c[na++] = bf; reverse(c, c + na); for (int i = 0; i < na; i++) printf("%d", c[i]); puts(""); } } }