#include <bits/stdc++.h>
using namespace std;
bool sortmd(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long t, i, j, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
    } else if (a < b) {
      j = b - a;
      if (j % 2 == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    } else {
      j = a - b;
      if (j % 2 == 0)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
  return 0;
}
