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