#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, n, m, x, y;
  long long t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    n = a - b;
    x = n % 2;
    m = b - a;
    y = m % 2;
    if (a == b) {
      cout << "\n0";
    } else if (a > b && x == 0 || b > a && y != 0) {
      cout << "\n1";
    } else {
      cout << "\n2";
    }
  }
}
