#include #include int main() { int q; std::cin >> q; for (int i = 0; i < q; i++) { std::string s; std::cin >> s; unsigned long long res; if (s.substr(0, 2) == "0b") { res = std::stoull(s.substr(2), NULL, 2); } else if (s.substr(0, 2) == "0o"){ res = std::stoull(s.substr(2), NULL, 8); } else { res = std::stoull(s, NULL, 0); } std::cout << res << std::endl; } return 0; }