local q = io.read("*n", "*l") local function solve() local s = io.read() if #s == 1 then return s end local head = s:sub(1, 2) if head == "0b" then local mul = 1LL local ans = 0LL for i = #s, 3, -1 do if s:sub(i, i) == "1" then ans = ans + mul end mul = mul + mul end ans = tostring(ans):gsub("LL", "") return ans elseif head == "0o" then local mul = 1LL local ans = 0LL for i = #s, 3, -1 do local b = s:byte(i) - 48 ans = ans + mul * b mul = mul * 8LL end ans = tostring(ans):gsub("LL", "") return ans elseif head == "0x" then local mul = 1LL local ans = 0LL for i = #s, 3, -1 do local b = s:byte(i) - 96 if b < 0 then b = s:byte(i) - 48 else b = s:byte(i) - 87 end ans = ans + mul * b mul = mul * 16 end ans = tostring(ans):gsub("LL", "") return ans else return s end end for iq = 1, q do print(solve()) end