#include <bits/stdc++.h>
using namespace std;
template <typename Type>
vector<Type> readArray(vector<Type> a, int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
  return a;
}
template <typename Type>
vector<vector<Type>> read2Array(vector<vector<Type>> a, int n, int m) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  return a;
}
template <typename Type>
void printArray(vector<Type> a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
template <typename Type>
void print2Array(vector<vector<Type>> a, int n, int m) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
}
template <typename Type>
using pq = priority_queue<Type>;
template <typename Type>
using pq_r = priority_queue<Type, vector<Type>, greater<Type>>;
bool prime(int x) {
  if (x == 1) return false;
  if (x == 2) return true;
  for (int i = 2; i <= sqrt(x) + 1; i++)
    if (x % i == 0) return false;
  return true;
}
void solve() {
  int a, b;
  cin >> a >> b;
  if (a == b)
    cout << 0 << "\n";
  else {
    if (b > a) {
      if ((a - b) % 2 != 0)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else {
      if ((a - b) % 2 == 0)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    }
  }
}
int main() {
  int tt = 1;
  cin >> tt;
  while (tt--) solve();
  return 0;
}
