#include <bits/stdc++.h>
int main() {
  int T;
  scanf("%d", &T);
  for (int tttt = 1; tttt <= T; tttt++) {
    int n, k;
    scanf("%d%d", &n, &k);
    if (n >= k) {
      if ((n + k) & 1)
        printf("1\n");
      else
        printf("0\n");
    } else {
      printf("%d\n", std::abs(n - k));
    }
  }
  return 0;
}
