#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  string m;
  int i, j, k, l, n;
  int a[100010];
  int count = 0;
  cin >> t;
  while (t > 0) {
    int a, b;
    cin >> a >> b;
    int count = abs(a - b);
    if (count == 0)
      cout << 0 << endl;
    else if (a < b) {
      if (count % 2 == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    } else {
      if (count % 2 == 0)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
    t--;
  }
  return 0;
}
