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