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