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