#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 9;
int main() {
  int t;
  while (scanf("%d", &t) != EOF) {
    while (t--) {
      int a, b;
      scanf("%d%d", &a, &b);
      if (a == b)
        printf("0\n");
      else if (a % 2 == b % 2) {
        if (a < b)
          printf("2\n");
        else
          printf("1\n");
      } else {
        if (a < b)
          printf("1\n");
        else
          printf("2\n");
      }
    }
  }
}
