#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
int reset(int mask, int pos) { return mask = mask & ~(1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
long long bigmod(long long b, long long p, long long md) {
  if (p == 0) return 1;
  if (p % 2 == 1) {
    return ((b % md) * bigmod(b, p - 1, md)) % md;
  } else {
    long long y = bigmod(b, p / 2, md);
    return (y * y) % md;
  }
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
    } else if (a < b) {
      int ans = 2;
      long long gap = b - a;
      if (gap % 2) ans = 1;
      cout << ans << endl;
    } else {
      int ans = 2;
      long long gap = a - b;
      if (gap % 2 == 0) ans = 1;
      cout << ans << endl;
    }
  }
  return 0;
}
