#include <bits/stdc++.h>
using namespace std;
const int N = 107;
int t;
void solve() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  cout << 1 + int((a < b) ^ ((b - a) & 1)) << endl;
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
}
