#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  while (n--) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "0"
           << "\n";
      continue;
    } else if (a > b) {
      if (a % 2 == 0 && b % 2 == 0 || a % 2 != 0 && b % 2 != 0) {
        cout << "1"
             << "\n";
      } else if (a % 2 == 0 && b % 2 != 0 || a % 2 != 0 && b % 2 == 0) {
        cout << "2"
             << "\n";
      }
    } else if (a < b) {
      if (a % 2 == 0 && b % 2 == 0 || a % 2 != 0 && b % 2 != 0) {
        cout << "2"
             << "\n";
      } else if (a % 2 == 0 && b % 2 != 0 || a % 2 != 0 && b % 2 == 0) {
        cout << "1"
             << "\n";
      }
    }
  }
}
