#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      if (a % 2 == 0 && b % 2 == 0) cout << 1 << endl;
      if (a % 2 == 0 && b % 2 != 0) cout << 2 << endl;
      if (a % 2 != 0 && b % 2 != 0) cout << 1 << endl;
      if (a % 2 != 0 && b % 2 == 0) cout << 2 << endl;
    }
    if (a < b) {
      if (a % 2 == 0 && b % 2 == 0) cout << 2 << endl;
      if (a % 2 == 0 && b % 2 != 0) cout << 1 << endl;
      if (a % 2 != 0 && b % 2 != 0) cout << 2 << endl;
      if (a % 2 != 0 && b % 2 == 0) cout << 1 << endl;
    }
    if (a == b) cout << 0 << endl;
  }
  return 0;
}
