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