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