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