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