#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  if (a % 2 == 0 && b % 2 == 0) {
    if (a > b)
      cout << 1 << endl;
    else
      cout << 2 << endl;
    return;
  }
  if (a % 2 != 0 && b % 2 != 0) {
    if (a > b)
      cout << 1 << endl;
    else
      cout << 2 << endl;
    return;
  }
  if (a % 2 != 0 && b % 2 == 0) {
    if (a < b)
      cout << 1 << endl;
    else
      cout << 2 << endl;
    return;
  }
  if (a < b)
    cout << 1 << endl;
  else
    cout << 2 << endl;
  return;
}
int main() {
  int TC;
  cin >> TC;
  while (TC--) {
    solve();
  }
  return 0;
}
