#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, x, a, b, ans, c;
void solve() {
  cin >> a >> b;
  if (a == b) cout << "0" << endl;
  if (a > b) {
    c = a - b;
    if (c == 1 || c % 2 != 0)
      cout << "2" << endl;
    else
      cout << "1" << endl;
  }
  if (a < b) {
    c = a - b;
    if (c % 2 == 0)
      cout << "2" << endl;
    else
      cout << "1" << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
