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