#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 2e6 + 10;
const int mod = 1e9 + 7;
int main() {
  int t, a, b;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &a);
    scanf("%d", &b);
    if (a == b) {
      printf("0\n");
    } else {
      if (a < b) {
        if ((a & 1) != (b & 1))
          printf("1\n");
        else
          printf("2\n");
      } else {
        if ((a & 1) != (b & 1))
          printf("2\n");
        else
          printf("1\n");
      }
    }
  }
  return 0;
}
