#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll t, n, m, k, l, i, j;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    if (n == m) {
      cout << 0 << endl;
    } else if (n < m) {
      l = n - m;
      if (l % 2) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    } else if (n > m) {
      l = n - m;
      if (l % 2) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    }
  }
  return 0;
}
