// Arup Guha
// 6/16/2023
// CF Div 3 Round 878 Problem B
// https://codeforces.com/contest/1840/problem/B

using namespace std;
#include <bits/stdc++.h>

int main() {

    int nC;
    cin >> nC;

    // Process cases.
    for (int loop=0; loop<nC; loop++) {

        // Get input.
        int n, k;
        cin >> n >> k;

        // Limitation is n...
        if (k>=30 || n<(1<<k))
            cout << n+1 << endl;

        // Here we can do every subset.
        else
            cout << (1<<k) << endl;
    }
    return 0;
}
