#include <bits/stdc++.h>
int main() {
  int t, i;
  long a, b, c, d;
  scanf("%d\n", &t);
  for (i = 0; i < t; i++) {
    scanf("%ld  %ld", &a, &b);
    if (a < b) {
      c = b - a;
      if (c % 2 != 0)
        d = 1;
      else
        d = 2;
    } else if (a == b) {
      d = 0;
    } else if (a > b) {
      c = a - b;
      if (c % 2 == 0)
        d = 1;
      else
        d = 2;
    }
    printf("%ld\n", d);
  }
}
