T= int(input())
tile = (1,1)
lucky = []
lucks = []
for _ in range(T):
    N = int(input())
    luckI1 = list(map(int,input().split()))
    luckI2 = list(map(int,input().split()))
    def Calculation(luckI1,luckI2):
        lucky.clear()
        for lmao in range(N):
            lucky.append(luckI1[lmao])
            lucky.append(luckI2[lmao])
        i = 1
        j = 1
        move = 1
        luck =  0
        tile = (1,1)
        while tile != (2,N):
            previous = (i,j)
            if i ==1:
                i = 2
                move += 1
            elif i == 2:
                i = 1
                j+=1
                move += 1
            if lucky[move-2] % 2 == lucky[move-1] % 2:
                luck += 1
            tile = (i,j)
        return luck
    ml = 0
    for x in range(1 << N):
        tI1 = luckI1[:]
        tI2 = luckI2[:]
        for r in range(N):
            if x & (1 << r):
                tI1[r],tI2[r] = tI2[r],tI1[r]
        ml = max(ml,Calculation(tI1,tI2))
    lucks.append(ml)
for z in lucks:
    print(z)