#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "0\n";
      continue;
    }
    if (a < b) {
      long long k = b - a;
      if (k % 2 != 0) {
        cout << "1\n";
      } else {
        cout << "2\n";
      }
    } else {
      long long k = a - b;
      if (k % 2 == 0) {
        cout << "1\n";
      } else
        cout << "2\n";
    }
  }
}
