#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = 0x3f3f3f3f;
inline bool IsOdd(int x) { return (x & 1); }
inline bool IsEven(int x) { return !(x & 1); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 0;
  cin >> t;
  while (t--) {
    int a = 0, b = 0;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
    } else if (IsOdd(a) && IsOdd(b)) {
      if (a > b) {
        cout << 1 << "\n";
      } else {
        cout << 2 << "\n";
      }
    } else if (IsOdd(a) && IsEven(b)) {
      if (a > b) {
        cout << 2 << "\n";
      } else {
        cout << 1 << "\n";
      }
    } else if (IsEven(a) && IsOdd(b)) {
      if (a > b) {
        cout << 2 << "\n";
      } else {
        cout << 1 << "\n";
      }
    } else if (IsEven(a) && IsEven(b)) {
      if (a > b) {
        cout << 1 << "\n";
      } else {
        cout << 2 << "\n";
      }
    }
  }
  return 0;
}
