#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b)
      cout << 0 << endl;
    else if (a > b) {
      if ((a % 2 == 1 && b % 2 == 1) || (a % 2 == 0 && b % 2 == 0)) {
        cout << 1 << endl;
      } else
        cout << 2 << endl;
    } else {
      if ((a % 2 == 1 && b % 2 == 1) || (a % 2 == 0 && b % 2 == 0)) {
        cout << 2 << endl;
      } else
        cout << 1 << endl;
    }
  }
}
