#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long _t;
  cin >> _t;
  while (_t--) {
    long long a, b;
    cin >> a >> b;
    ;
    a = a - b;
    long long s = 0;
    if (a) {
      if (a < 0) {
        if (abs(a) % 2) {
          cout << 1 << "\n";
        } else {
          cout << 2 << "\n";
        }
      } else {
        if (a % 2) {
          cout << 2 << "\n";
        } else {
          cout << 1 << "\n";
        }
      }
    } else {
      cout << 0 << "\n";
    }
  }
}
