#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b;
  cin >> t;
  while (t--) {
    int count = 0;
    cin >> a >> b;
    while (a != b) {
      if (b > a) {
        if ((b - a) % 2 == 0) {
          a += (b - a);
          count += 2;
        } else {
          a += (b - a);
          count++;
        }
      } else {
        if ((a - b) % 2 == 0) {
          a -= (a - b);
          count++;
        } else {
          a -= (a - b);
          count += 2;
        }
      }
    }
    cout << count << endl;
  }
}
