t=int(input())
sreca=[]
for k in range(t):
    n=int(input())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    if (b[0])%2!=(a[1]%2) and (a[0])%2!=(b[0])%2:
        pom1=a[0]
        a[0]=b[0]
        b[0]=pom1
    for i in range(2,n):
        if (b[i-1])%2!=(a[i])%2 and (a[i])%2!=(b[i])%2:
            pom2=a[i]
            a[i]=b[i]
            b[i]=pom2
    sreca.append(0)
    for l in range(n):
        if (a[l])%2==(b[l])%2:
            sreca[k]+=1
        if l<n-1 and (b[l])%2==(a[l+1])%2:
            sreca[k]+=1
for k in range(t):
    print(sreca[k])