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