#include #include #include #include #include using namespace std; const int MaxN = 1e7; int T; char s[MaxN + 5]; int a[MaxN + 5]; int main() { scanf("%d", &T); for (int cas = 1; cas <= T; cas++) { scanf("%s", s); int len = strlen(s); if (len == 1) printf("Uncertain\n"); else { for (int i = 0; i < len; i++) a[i + 1] = s[i] - '0'; sort(a + 1, a + len + 1); if (a[len - 1] == 0) printf("Uncertain\n"); else { int c, pos; for (int i = 1; i <= len; i++) if (a[i] > 0) { c = a[i]; pos = i; break; } for (int i = pos + 1; i <= len; i++) a[i - 1] = a[i]; len = len - 1; for (int i = 1; i <= len; i++) { int p = a[i]; a[i] = (p + c) % 10; c = (p + c) / 10; if (c == 0) break; } if (c != 0) a[++len] = c; for (int i = len; i >= 1; i--) printf("%d", a[i]); printf("\n"); } } } }