#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i, j, diff, a, b, temp;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
    }
    if (a > b) {
      diff = a - b;
      if (diff % 2 == 0) {
        cout << 1 << "\n";
      } else {
        cout << 2 << "\n";
      }
    }
    if (b > a) {
      diff = b - a;
      if (diff % 2 == 0) {
        cout << 2 << "\n";
      } else {
        cout << 1 << "\n";
      }
    }
  }
  return 0;
}
