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