#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long
typedef int uci;
#define int long long

//! function insert

uci main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int m;
    cin >> m;
    while(m--){
        int n, k;
        cin >> n >> k;

        if ((((1ll<<k)-1)&n) == 0){
            cout << 1 << '\n';
        }else
            cout << 2 << '\n';
    }

}
