#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, c, d, e, i, j, k, l;
    cin >> a >> b;
    if (a <= b)
      cout << abs(a - b) << endl;
    else if (a % 2 + b % 2 == 1)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
}
