/* -*- coding: utf-8 -*- * * 2393.cc: No.2393 Bit Grid Connected Component - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { ll x; int y; scanf("%lld%d", &x, &y); while ((x >> (y + 1)) & 1) y++; printf("%lld\n", (1LL << (y + 1)) - 1); } return 0; }