#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX 100010
ll N,Q,L;
ll x[MAX],a,b;

int nex[MAX][70];

void compute() {
  rep(i,N) {
    nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1;
    assert( nex[i][0] != 0 );
  }

  rep(j,67) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j];
  cin >> Q;
  rep(_,Q) {
    cin >> a >> b;
    --a, --b;
    if( !( a < b ) ) swap(a,b);
    //cout << "[*] " << a << " -> " << b << endl;
    ll cost = 0;
    while( a != b ) {
      int go = 0;
      go = upper_bound(nex[a],nex[a]+67,b) - nex[a] - 1;
      cost += (1LL<<go);
      //cout << "  " << a <<" -[" << go << "]->" << nex[a][go] << endl;
      a = nex[a][go];
    }
    cout << cost << endl;
  }
}

int main() {
