#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t T, i; cin >> T; vector> query(T); for (i = 0; i != T; ++i) cin >> query[i].first >> query[i].second; for (i = 0; i != T; ++i) { for (; (query[i].first >> query[i].second) & 1; ++query[i].second); cout << (UINT64_C(1) << query[i].second) - 1 << '\n'; } return 0; }