#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a < b) {
      long long temp = b - a;
      if (temp & 1) {
        cout << "1" << endl;
      } else {
        cout << "2" << endl;
      }
    }
    if (a > b) {
      long long temp = a - b;
      if (temp & 1) {
        cout << "2" << endl;
      } else {
        cout << "1" << endl;
      }
    }
    if (a == b) cout << "0" << endl;
  }
}
