#include using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; const string TARGET_NO = "0539"; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; cin.ignore(); vector vs(t); for (auto&& it : vs) getline(cin, it); stringstream ss; for (auto&& v : vs) { bool f{ false }; char carry{ 1 }; auto it = v.rbegin(); while (carry && it != v.rend()) { if (*it >= '0' && *it <= '8') { ++(*it); f = true; carry = 0; } else if (*it == '9') { *it = '0'; if (it + 1 == v.rend()) { v = "1" + v; break; } else f = true; } else { if (f) { v.insert(v.rend() - it, string("1")); break; } } ++it; } ss << v << "\n"; } cout << ss.str(); return 0; }