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