#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
      if (a == b)
        cout << 0 << "\n";
      else if ((b - a) % 2 == 1)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else {
      if (a == b)
        cout << 0 << "\n";
      else if ((a - b) % 2 == 0)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    }
  }
}
