#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b;
  cin >> a >> b;
  if (a == b)
    cout << 0 << endl;
  else if ((a > b && (a - b) % 2 == 0) || (a < b && (a - b) % 2 != 0))
    cout << 1 << endl;
  else
    cout << 2 << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
