#include <bits/stdc++.h>
using namespace std;
using i8 = char;
using ui8 = unsigned char;
using i16 = short;
using u16 = unsigned short;
using i32 = int;
using ui32 = unsigned int;
using i64 = long long int;
using ui64 = unsigned long long int;
void task();
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  int t = 1;
  cin >> t;
  while (t--) {
    task();
  }
  return 0;
}
void task() {
  i64 a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  if (a < b) {
    if ((b - a) % 2 == 0) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
    return;
  }
  if ((a - b) % 2 == 0) {
    cout << 1 << endl;
  } else {
    cout << 2 << endl;
  }
}
