#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, x;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a < b) {
      x = b - a;
      x % 2 == 0 ? cout << 2 : cout << 1;
    } else if (a > b) {
      x = a - b;
      x % 2 == 0 ? cout << 1 : cout << 2;
    } else
      cout << 0;
    cout << endl;
  }
}
