t = int(input())
p = []
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ia = 0
    ib = 0
    ja = n-1
    jb = n-1
    round = 0
    winner = "Bob"
    while round < n-1 and winner == "Bob":
        if (a[ia] == b[ib] and a[ja] == b[jb]) or (a[ja] == b[ib] and a[ia] == b[jb]):
            if a[ia] == b[ib]:
                ia += 1
                ib += 1
            elif a[ia] == b[jb]:
                ia += 1
                jb -= 1
            elif a[ja] == b[jb]:
                ja -= 1
                jb -= 1
            elif a[ja] == b[ib]:
                ib += 1
                ja -= 1
        else:
            winner = "Alice"
        round += 1
    p.append(winner)
for x in p:
    print(x)