t = int(raw_input())
while t:
    n, a, b = [int(i) for i in raw_input().split()]
    a = bin(a)[2:]
    b = bin(b)[2:]
    ai, bi = 1, 1
    while a[-ai] == "0":
        ai += 1
    while b[-bi] == "0":
        bi += 1
    print n-min(ai,bi)+1
    t -= 1