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