#include <bits/stdc++.h>
using namespace std;
long long int binary_exp(long long int a, long long int n) {
  long long int i = 1;
  while (n > 0) {
    if (n % 2 == 1) i = (i * a) % 1000000007;
    a = (a * a) % 1000000007;
    n /= 2;
  }
  return i;
}
long long int IsPrime(long long int n) {
  if (n == 0 || n == 1) return n;
  if (n % 2 == 0) return (long long int)2;
  if (n % 3 == 0)
    return (long long int)3;
  else {
    for (long long int i = 5; i * i <= n; i += 6) {
      if (n % i == 0) return i;
      if (n % (i + 2) == 0) return (i + 2);
    }
    return n;
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  int t;
  cin >> t;
  while (t--) {
    long long int a, b, n, i, j, k;
    cin >> a >> b;
    if (a == b)
      cout << "0";
    else if (a > b) {
      if ((a - b) % 2 == 0)
        cout << 1;
      else
        cout << 2;
    } else {
      if ((b - a) % 2 == 1)
        cout << 1;
      else
        cout << 2;
    }
    cout << "\n";
  }
}
