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