T= int(input())
tile = (1,1)
for _ in range(T):
    N = int(input())
    luckI1 = list(map(int,input().split()))
    luckI2 = list(map(int,input().split()))
    i = 1
    j = 1
    luck =  0
    while tile != (2,N):
        if i ==1:
            i = 2
            if luckI1[j-2] %2 == luckI2[j-1] %2:
                luck += 1
        elif i == 2:
            i = 1
            j+=1
            if luckI2[j-1] %2 == luckI1[j-2] %2:
                luck += 1
        tile = (i,j)
    print(luck)