#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 100;
const double PI = 3.1415926536;
vector<char> v;
long long n, m, k, t, sum, l, r, p, e, d, c, a, b;
long long ans;
bool f;
string s[10];
set<long long> st;
map<char, int> mp1, mp2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
      continue;
    }
    n = abs(a - b);
    if (b > a) {
      if (n % 2 == 1)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else {
      if (n % 2 == 1)
        cout << 2 << "\n";
      else
        cout << 1 << "\n";
    }
  }
  return 0;
}
