#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  if (k > n)
    cout << k - n << "\n";
  else {
    if ((n - k) % 2 == 0)
      cout << 0 << "\n";
    else
      cout << 1 << "\n";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
