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