#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  for (int i = 2; i < n; i++)
    if (n % i == 0) return false;
  return true;
}
const int N = 1e5 + 7;
long long l, tr, n, m, sum, mini, maxi, a, b, c, x, y;
long long t[N];
set<int> vis;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (cin >> tr; tr--;) {
    cin >> a >> b;
    if (a > b) {
      if ((a - b) % 2) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    } else if (b > a) {
      if ((b - a) % 2) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    } else {
      cout << 0 << endl;
    }
  }
}
