#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, ans;
    cin >> a;
    cin >> b;
    if (b % 2 != 0 && b > a) {
      ans = b - a;
      if (ans % 2 != 0)
        cout << "1";
      else
        cout << "2";
    }
    if (b % 2 == 0 && b > a) {
      ans = b - a;
      if (ans % 2 == 0)
        cout << "2";
      else
        cout << "1";
    }
    if (a == b) cout << "0";
    if (b % 2 == 0 && a > b) {
      ans = a - b;
      if (ans % 2 == 0)
        cout << "1";
      else
        cout << "2";
    }
    if (b % 2 != 0 && a > b) {
      ans = a - b;
      if (ans % 2 == 0)
        cout << "1";
      else
        cout << "2";
    }
    cout << endl;
  }
  return 0;
}
