#include <bits/stdc++.h>

using namespace std;

int main() {
	int t; cin >> t;
	while (t--) {
		long long n, a, b;
		cin >> n >> a >> b;
		a--, b--;
		long long ca = 0, cb = 0, bs = 1;
		while (a&(bs)) {
			bs *= 2;
			ca++;
		}
		bs = 1;
		while (b&(bs)) {
			bs *= 2;
			cb++;
		}
		cout << min(n-ca, n-cb) << endl;
	}
}