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