#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    int s = 0;
    while (a != b) {
      int h = a - b;
      if (h > 0) {
        if (h % 2 == 0) {
          a -= h;
          s++;
        } else {
          a -= h + 1;
          s++;
        }
      } else {
        h = h * -1;
        if (h % 2 == 1) {
          a += h;
          s++;
        } else {
          a += (h - 1);
          s++;
        }
      }
    }
    cout << s << '\n';
  }
  return 0;
}
