def okreni(a1,a2,i):
    k=a1[i]
    f=a2[i]
    a1[i]=f
    a2[i]=k
t=int(input())
svitestovi=[]
for i in range(t):
    sreca=0
    n=int(input())
    k1=list(map(int,input().split()))
    k2=list(map(int,input().split()))
    for i1 in range(2):
        if i1%2==0:
            okreni(k1,k2,0)
        if n>1:
            for i2 in range(2):
                if i2%2==0:
                    okreni(k1,k2,1)
                if n>2:
                    for i3 in range(2):
                        if i3%2==0:
                            okreni(k1,k2,2)
                        if n>3:
                            for i4 in range(2):
                                if i4%2==0:
                                    okreni(k1,k2,3)
                                if n>4:
                                    for i5 in range(2):
                                        if i5%2==0:
                                            okreni(k1,k2,4)
                                        if n>5:
                                            for i6 in range(2):
                                                if i6%2==0:
                                                    okreni(k1,k2,5)
                                                if n>6:
                                                    for i7 in range(2):
                                                        if i7%2==0:
                                                            okreni(k1,k2,6)
                                                        if n>7:
                                                            for i8 in range(2):
                                                                if i8%2==0:
                                                                    okreni(k1,k2,7)
                                                                if n>8:
                                                                    for i9 in range(2):
                                                                        if i9%2==0:
                                                                            okreni(k1,k2,8)
                                                                        if n>9:
                                                                            for i10 in range(2):
                                                                                if i10%2==0:
                                                                                    okreni(k1,k2,9)
                                                                                trensreca=0
                                                                                for l in range(n-1):
                                                                                    if k1[l]%2==k2[l]%2:
                                                                                        trensreca+=1
                                                                                    if k2[l]%2==k1[l+1]%2:
                                                                                        trensreca+=1
                                                                                if k1[n-1]%2==k2[n-1]%2:
                                                                                    trensreca+=1
                                                                                sreca=max(sreca,trensreca)
                                                                else:
                                                                    trensreca=0
                                                                    for l in range(n-1):
                                                                        if k1[l]%2==k2[l]%2:
                                                                            trensreca+=1
                                                                        if k2[l]%2==k1[l+1]%2:
                                                                            trensreca+=1
                                                                    if k1[n-1]%2==k2[n-1]%2:
                                                                        trensreca+=1
                                                                    sreca=max(sreca,trensreca)
                                                        else:
                                                            trensreca=0
                                                            for l in range(n-1):
                                                                if k1[l]%2==k2[l]%2:
                                                                    trensreca+=1
                                                                if k2[l]%2==k1[l+1]%2:
                                                                    trensreca+=1
                                                            if k1[n-1]%2==k2[n-1]%2:
                                                                trensreca+=1
                                                            sreca=max(sreca,trensreca)
                                                else:
                                                    trensreca=0
                                                    for l in range(n-1):
                                                        if k1[l]%2==k2[l]%2:
                                                            trensreca+=1
                                                        if k2[l]%2==k1[l+1]%2:
                                                            trensreca+=1
                                                    if k1[n-1]%2==k2[n-1]%2:
                                                        trensreca+=1
                                                    sreca=max(sreca,trensreca)
                                        else:
                                            trensreca=0
                                            for l in range(n-1):
                                                if k1[l]%2==k2[l]%2:
                                                    trensreca+=1
                                                if k2[l]%2==k1[l+1]%2:
                                                    trensreca+=1
                                            if k1[n-1]%2==k2[n-1]%2:
                                                trensreca+=1
                                            sreca=max(sreca,trensreca)
                                else:
                                    trensreca=0
                                    for l in range(n-1):
                                        if k1[l]%2==k2[l]%2:
                                            trensreca+=1
                                        if k2[l]%2==k1[l+1]%2:
                                            trensreca+=1
                                    if k1[n-1]%2==k2[n-1]%2:
                                        trensreca+=1
                                    sreca=max(sreca,trensreca)
                        else:
                            trensreca=0
                            for l in range(n-1):
                                if k1[l]%2==k2[l]%2:
                                    trensreca+=1
                                if k2[l]%2==k1[l+1]%2:
                                    trensreca+=1
                            if k1[n-1]%2==k2[n-1]%2:
                                trensreca+=1
                            sreca=max(sreca,trensreca)
                else:
                    trensreca=0
                    for l in range(n-1):
                        if k1[l]%2==k2[l]%2:
                            trensreca+=1
                        if k2[l]%2==k1[l+1]%2:
                            trensreca+=1
                    if k1[n-1]%2==k2[n-1]%2:
                        trensreca+=1
                    sreca=max(sreca,trensreca)
        else:
            trensreca=0
            for l in range(n-1):
                if k1[l]%2==k2[l]%2:
                    trensreca+=1
                if k2[l]%2==k1[l+1]%2:
                    trensreca+=1
            if k1[n-1]%2==k2[n-1]%2:
                trensreca+=1
            sreca=max(sreca,trensreca)
    svitestovi.append(sreca)
for i in range(t):
    print(svitestovi[i])