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