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