local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local q = io.read("*n", "*l") for iq = 1, q do local x, y = io.read():match("(%d+) (%d+)") x = lltonumber(x) y = tonumber(y) local c = y for i = 1, y do x = x / 2LL end while x % 2LL == 1LL do c = c + 1 x = x / 2LL end local ans = 1LL for i = 1, c do ans = ans + ans end ans = ans - 1LL ans = tostring(ans):gsub("LL", "") print(ans) end