#include <bits/stdc++.h>
using namespace std;

long long t, a, b;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen("BIENDOI.INP", "r", stdin);
    freopen("BIENDOI.OUT", "w", stdout);

    cin >> t;
    while (t--) {
        cin >> a >> b;
        
        if (a == b) {
            cout << 0 << endl;
        } else if (a < b) {
            int m = b - a;
            cout << (m % 2 == 0 ? 2 : 1) << endl;
        } else { 
            int n = a - b;
            cout << (n % 2 == 0 ? 1 : 2) << endl;
        }
    }
    
    return 0;
}
