#include <iostream>

using namespace std;

int main() {
  int t;
  cin >> t;
  while(t--) {
    int n, k;
    cin >> n >> k;
    int lhs = n, rhs = n;
    while(k--) {
      lhs = lhs / 2;
      rhs = (rhs+1)/2;
    }
    if(lhs == rhs) cout << "1\n";
    else cout << "2\n";
  }
}