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