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()))
    for lmao in range(N):
        lucky.append(luckI1[lmao])
        lucky.append(luckI2[lmao])
    i = 1
    j = 1
    move = 1
    luck =  0
    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-1] % 2 == lucky[move] % 2:
            luck += 1
        tile = (i,j)
    lucks.append(luck)
for z in lucks:
    print(z)