#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b)
      cout << 0 << "\n";
    else if (a > b) {
      if ((a - b) % 2)
        cout << 2 << "\n";
      else
        cout << 1 << "\n";
    } else {
      if ((b - a) % 2)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    }
  }
  return 0;
}
