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