#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5 + 10;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (b == a)
      cout << 0;
    else if (a < b) {
      if ((b - a) % 2)
        cout << 1;
      else
        cout << 2;
    } else if (a > b) {
      if ((a - b) % 2)
        cout << 2;
      else
        cout << 1;
    }
    cout << "\n";
  }
  return 0;
}
