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