#include <bits/stdc++.h>
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
using namespace std;
int main() {
  cin.tie(NULL), ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      if ((b - a) % 2 == 0)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else if (a == b)
      cout << 0 << "\n";
    else {
      if ((b - a) % 2 != 0)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    }
  }
}
