#include <bits/stdc++.h>
using namespace std;
long long M = 998244353;
long long gcdf(long long a, long long b) {
  while (a != 0 && b != 0) {
    if (a > b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  return max(a, b);
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long gcd(long long a, long long b);
long long power(long long x, unsigned long long y, unsigned long long m);
long long modInverse(long long a, long long m) {
  long long g = gcd(a, m);
  if (g != 1)
    cout << "Inverse doesn't exist";
  else {
    return power(a, m - 2, m);
  }
}
long long power(long long x, unsigned long long y, unsigned long long m) {
  if (y == 0) return 1;
  long long p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  boost();
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (b > a) {
      if ((b - a) % 2 == 1)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else if (b < a) {
      if ((a - b) % 2 == 0)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else
      cout << 0 << endl;
  }
}
