#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long m = 1e9 + 7;
const long long N = 1e5 + 7;
bool prime[N];
vector<int> p;
void sieve(int n) {
  fill(prime, prime + n, true);
  for (int i = 2; i < n; i++) {
    if (prime[i]) p.push_back(i);
    for (int j = 0; j < p.size() and i * p[j] < n; j++) {
      prime[i * p[j]] = false;
      if (i % p[j] == 0) break;
    }
  }
}
long long modp(long long a, long long b) {
  if (b == 0) return 1;
  long long u = modp(a, b >> 1);
  u = (u * u) % m;
  if (b & 1) return (u * a) % m;
  return u;
}
long long fac[N];
long long invfac[N];
void init_fact(int n) {
  fac[0] = fac[1] = 1;
  for (int i = 2; i <= n; i++) {
    fac[i] = i * fac[i - 1];
  }
  for (int i = 0; i <= n; i++) {
    invfac[i] = modp(fac[i], m - 2);
  }
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long diff = b - a;
    if (diff == 0)
      cout << 0;
    else if (diff > 0) {
      if (diff & 1)
        cout << 1;
      else
        cout << 2;
    } else if (diff < 0) {
      if (diff & 1)
        cout << 2;
      else
        cout << 1;
    }
    cout << "\n";
  }
}
