#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long double dist(long double x1, long double arayikhalatyan, long double x2,
                 long double y2) {
  return ((x1 - x2) * (x1 - x2) +
          (arayikhalatyan - y2) * (arayikhalatyan - y2));
}
char vow[] = {'a', 'e', 'i', 'o', 'u'};
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const long long int N = 5010;
const long long int mod = 1e9 + 7;
const long double pi = acos(-1);
const int T = 150;
long long int bp(long long int a, long long int b = mod - 2LL) {
  long long int ret = 1;
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a;
    a %= mod;
    b >>= 1;
  }
  return ret;
}
int t, a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b) cout << 0 << "\n";
    if (a > b) {
      if (a % 2 == b % 2)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else if (a < b) {
      if (a % 2 == b % 2)
        cout << 2 << "\n";
      else
        cout << 1 << "\n";
    }
  }
  return 0;
}
