#include #include #include using namespace std; const int maxn = int(1e8) + 1000; char str[maxn], A[maxn]; int num[10]; int main(){ int t; int count, k, c; scanf("%d", &t); while (t--){ memset(num, 0, sizeof(num)); count = 0; scanf("%s", str); for (int i = 0; str[i]; i++){ if (str[i] != '0')count++; num[str[i] - '0']++; } if (count < 2) { printf("Uncertain\n"); continue; } for (int i = 1; i < 10; i++) if (num[i] != 0){ c = i; num[i]--; break; } k = 0; for (int i = 0; i < 10; i++) while (num[i]){ A[k++] = '0' + i; num[i]--; } for (int i = 0; i < k; i++){ A[i] += c; c = 0; if (A[i] > '9'){ A[i] -= 10; c = 1; } else break; } if (c)printf("%d", c); for (int i = k - 1; i >= 0; i--)printf("%c", A[i]); printf("\n"); } return 0; }