#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, tc = 0;
  scanf("%d", &T);
  while (T--) {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
      int d = b - a;
      if (d <= 1) {
        cout << d << endl;
        continue;
      }
      if (d % 2 == 1) {
        puts("1");
        continue;
      } else {
        puts("2");
        continue;
      }
    } else {
      int d = b - a;
      if (d % 2 == 0) {
        puts("1");
        continue;
      } else {
        puts("2");
        continue;
      }
    }
  }
  return 0;
}
