#include #include #include #include using namespace std; int main() { int t, a[11]; ios :: sync_with_stdio(false); cin >> t; while(t--) { string s; cin >> s; int n = s.size(); memset(a, 0, sizeof(a)); for(int i = 0; i < n; i++) { a[s[i]-'0']++; } string ss=""; int ans = 0; for(int i = 1; i <= 9; i++) { if(a[i] > 0) { a[i]--; ans = i; break; } } int flag = 1; for(int i = 1; i <= 9; i++) { if(a[i]) { flag = 0; break; } } if(ans == 0||flag) { cout<<"Uncertain\n"; } else { for(int i = 9; i >=0 ; i--) { for(int j = 0; j < a[i]; j++) { ss += i + '0'; } } int now = ans; for(int i = n-2; i >= 0; i--) { now += ss[i] - '0'; ss[i] = now % 10 + '0' ; now = now / 10; if(now == 0) break; } if(now > 0) { cout << 1 <