#include using namespace std; int main(){ int T; string s; map mp{{'b', 2}, {'o', 8}, {'x', 16}}; cin >> T; while(cin >> s){ cout << (s.size() < 2 || isdigit(s[1]) ? stoll(s) : stoll(s.substr(2), 0, mp[s[1]])) << '\n'; } }