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