#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
using namespace std;
void solve() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long a, b;
  cin >> a >> b;
  bool m = a % 2, n = b % 2;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  if (a < b) {
    cout << (m != n ? "1\n" : "2\n");
    return;
  }
  if (a > b) {
    cout << (m != n ? "2\n" : "1\n");
    return;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
}
