#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, r, c;
    string s, s1, s2;
    long long a, b;
    set<int> se;
    pair<int, int> A[200010];
    long long x, y, ad, bd, sum = 0, flag = 0, k = 0;
    int q;
    int sum1 = 0;
    cin >> a >> b;
    bd = n;
    if (a == b) {
      cout << "0" << endl;
    } else if (a < b) {
      if ((b - a) % 2 == 1) {
        cout << "1" << endl;
      } else {
        cout << "2" << endl;
      }
    } else {
      if ((a - b) % 2 == 0) {
        cout << "1" << endl;
      } else {
        cout << "2" << endl;
      }
    }
  }
  return 0;
}
