#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
void solve() {
  int a, b;
  cin >> a >> b;
  int c = 0;
  if (a > b && (a - b) % 2 == 0)
    ans.push_back(1);
  else if (a > b && (a - b) % 2 == 1)
    ans.push_back(2);
  else if (b > a && (b - a) % 2 == 0)
    ans.push_back(2);
  else if (a < b && (b - a) % 2 != 0)
    ans.push_back(1);
  else
    ans.push_back(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  for (auto x : ans) cout << x << '\n';
}
