#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, n, k, t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if (k >= n)
      cout << (k - n) << endl;
    else
      cout << (n - k) % 2 << endl;
  }
}
