1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
#include <stdint.h>

using namespace std;


void test() {
  int n, k;
  cin >> n >> k;
  
  if(k < (n + 1) / 2) {
    cout << "0\n";
    return;
  }
  
  cout << (n & 1) << '\n';
}


int main() {
  ios_base::sync_with_stdio(false);
#ifndef LOCAL_TESTS
  cin.tie(NULL);
#endif
  
  int t;
  cin >> t;
  while(t --> 0) test();
  
  return 0;
}