#include <bits/stdc++.h>
using namespace std;
struct coord {
  int x, y;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "0\n";
    } else if (a < b) {
      if (a % 2 != b % 2) {
        cout << "1\n";
      } else {
        cout << "2\n";
      }
    } else {
      if (a % 2 == b % 2) {
        cout << "1\n";
      } else {
        cout << "2\n";
      }
    }
  }
}
