#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ar;
  vector<int> ar1;
  ar.resize(n);
  ar1.resize(n);
  for (int i = 0; i < n; i++) cin >> ar[i] >> ar1[i];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int a = ar[i];
    int b = ar1[i];
    int razn = a - b;
    if (razn > 0) {
      if (razn % 2 == 0)
        sum++;
      else
        sum += 2;
    } else if (razn < 0) {
      if (abs(razn) % 2 == 1)
        sum++;
      else
        sum += 2;
    } else
      sum = 0;
    cout << sum << endl;
    sum = 0;
  }
}
