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