#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b;
  cin >> a >> b;
  int ans;
  if (a == b) {
    ans = 0;
  } else if (a < b) {
    if ((a & 1) == (b & 1)) {
      ans = 2;
    } else {
      ans = 1;
    }
  } else if (a > b) {
    if ((a & 1) == (b & 1)) {
      ans = 1;
    } else {
      ans = 2;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  for (int c = 0; c < t; c++) {
    solve();
  }
}
