#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5, MOD = 1e9;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long fastpowMOD(long long a, long long p, long long MOD) {
  if (p == 0) return 1;
  long long z = fastpowMOD(a, p / 2, MOD);
  z = (z * z) % MOD;
  if (p % 2) z = (z * a) % MOD;
  return z;
}
bool seive[100005];
void SieveOfEratosthenes(long long n) {
  memset(seive, true, sizeof(seive));
  for (long long p = 2; p * p <= n; p++)
    if (seive[p] == true)
      for (long long i = p * p; i <= n; i += p) seive[i] = false;
}
typedef struct {
  long long one, two, three;
} data;
long long m = 998244353;
long long a[200004];
vector<long long> v[200004];
long long sum[200004];
long long res[200004];
long long ans = 0;
void dfs(long long i, long long j, long long &res, long long dis) {
  sum[i] = a[i];
  res += (a[i] * dis);
  for (auto x : v[i]) {
    if (x != j) {
      dfs(x, i, res, dis + 1);
      sum[i] += sum[x];
    }
  }
}
void dfs2(long long i, long long j, long long &res1) {
  ans = max(ans, res1);
  for (auto x : v[i]) {
    if (x != j) {
      res1 = res1 - sum[x];
      sum[i] -= sum[x];
      sum[x] += sum[i];
      res1 += sum[i];
      dfs2(x, i, res1);
      res1 -= sum[i];
      sum[x] -= sum[i];
      sum[i] += sum[x];
      res1 += sum[x];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long test = 1; test <= t; test++) {
    long long a, b;
    cin >> a >> b;
    if (b == a)
      cout << 0;
    else if (b > a) {
      if ((b - a) & 1)
        cout << 1;
      else {
        cout << 2;
      }
    } else {
      if ((a - b) & 1)
        cout << 2;
      else
        cout << 1;
    }
    cout << endl;
  }
}
