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