#include <bits/stdc++.h>
using namespace std;
int testCase;
int iinf = 1e9 + 1;
long long inf = 1e16 + 1;
void solve() {
  long long a;
  cin >> a;
  long long b;
  cin >> b;
  if (a == b)
    cout << "0\n";
  else if (a > b) {
    if ((a - b) % 2 == 0)
      cout << "1\n";
    else
      cout << "2\n";
  } else {
    if ((b - a) % 2 == 0)
      cout << "2\n";
    else
      cout << "1\n";
  }
}
int main() {
  cin >> testCase;
  while (testCase--) {
    solve();
  };
}
