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