#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int T, n, k;
  cin >> T;
  while (T--) {
    cin >> n >> k;
    if (n > k) {
      int t = n + k;
      if (t & 1)
        printf("1\n");
      else
        printf("0\n");
    } else
      printf("%d\n", k - n);
  }
  return 0;
}
