#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;
void solve() {
  int a, b;
  cin >> a >> b;
  int x = abs(a - b) % 2;
  int ans;
  if (a - b == 0) {
    cout << 0 << '\n';
    return;
  }
  if (x) {
    if (a < b)
      ans = 1;
    else
      ans = 2;
  } else {
    if (a > b)
      ans = 1;
    else
      ans = 2;
  }
  cout << ans << '\n';
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
