#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int a, b;
  int C;
  int odd = 1, even = 0;
  cin >> C;
  while (C--) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
    } else if (a < b) {
      int k = b - a;
      if (k % 2 == odd) {
        cout << 1 << "\n";
      } else {
        cout << 2 << "\n";
      }
    } else {
      int k = a - b;
      if (k % 2 == even) {
        cout << 1 << "\n";
      } else {
        cout << 2 << "\n";
      }
    }
  }
}
