#include <bits/stdc++.h>
const long double pi = acos(-1);
const long long mod = 1e9 + 7, N = 1e5 + 5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      if ((a % 2 == 0 && b % 2 == 0) || (a % 2 != 0 && b % 2 != 0))
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else if (a < b) {
      if ((a % 2 == 0 && b % 2 == 0) || (a % 2 != 0 && b % 2 != 0))
        cout << 2 << endl;
      else
        cout << 1 << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
