#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
void solve() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << '\n';
    return;
  }
  if (b > a && (b - a) % 2 == 1) {
    cout << "1\n";
    return;
  }
  if (b < a && (a - b) % 2 == 0) {
    cout << "1\n";
    return;
  }
  cout << "2\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
