#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  cin >> n;
  while (n--) {
    cin >> x >> y;
    if (x < y) {
      if ((x - y) & 1) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    } else if (x > y) {
      if ((x - y) & 1) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    } else {
      cout << 0 << endl;
    }
  }
}
