#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int temperature;
    long long int a12, b11;
    long long int solution;
    cin >> a12 >> b11;
    if (b11 == a12) {
      solution = 0;
    } else if (b11 > a12) {
      temperature = b11 - a12;
      if (temperature & 1) {
        solution = 1;
      } else {
        solution = 2;
      }
    } else {
      temperature = a12 - b11;
      if (temperature & 1) {
        solution = 2;
      } else {
        solution = 1;
      }
    }
    cout << solution << "\n";
  }
  return 0;
}
