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