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