#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, g, p = 0;
  cin >> n;
  while (n--) {
    g = 0;
    cin >> a >> b;
    if ((a - b) == 0) {
      cout << "0" << endl;
    } else if ((a - b) < 0 && (b - a) % 2 == 1) {
      a += (b - a);
      if (a == b) g = 1;
      cout << g << endl;
    } else if ((a - b) < 0 && (b - a) % 2 == 0) {
      int k = (b - a);
      int f = 2;
      g = min(k, f);
      cout << g << endl;
    } else if ((a - b) > 0 && (a - b) % 2 == 1) {
      g = 2;
      cout << g << endl;
    } else if ((a - b) > 0 && (a - b) % 2 == 0) {
      g = 1;
      cout << 1 << endl;
    }
  }
  return 0;
}
