#include #include void solve() { std::string s; std::getline(std::cin, s); std::string tmp, t; while (!s.empty() && !std::isdigit(s.back())) { tmp.push_back(s.back()); s.pop_back(); } while (!s.empty() && std::isdigit(s.back())) { t.push_back(s.back()); s.pop_back(); } if (!t.empty()) { int carry = 1; for (auto& c : t) { c += carry; carry = 0; if (c > '9') { c = '0'; carry = 1; } } if (carry) t.push_back('1'); } while (!t.empty()) { s.push_back(t.back()); t.pop_back(); } while (!tmp.empty()) { s.push_back(tmp.back()); tmp.pop_back(); } std::cout << s << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int q; std::cin >> q; { std::string tmp; std::getline(std::cin, tmp); } while (q--) solve(); return 0; }