from itertools import product

def okreni(a1, a2, i):
    a1[i], a2[i] = a2[i], a1[i]

def trenutnasreca(k1, k2, n):
    sreca = 0
    for l in range(n - 1):
        if k1[l] % 2 == k2[l] % 2:
            sreca += 1
        if k2[l] % 2 == k1[l + 1] % 2:
            sreca += 1
    if k1[n - 1] % 2 == k2[n - 1] % 2:
        sreca += 1
    return sreca

t = int(input())
svitestovi = []

for _ in range(t):
    n = int(input())
    k1 = list(map(int, input().split()))
    k2 = list(map(int, input().split()))

    najsreca = 0
    for pattern in product([0, 1], repeat=n):
        l1, l2 = k1[:], k2[:]
        for i, zameni in enumerate(pattern):
            if zameni:
                okreni(l1, l2, i)
        najsreca = max(najsreca, trenutnasreca(l1, l2, n))
    
    svitestovi.append(najsreca)

for rezultat in svitestovi:
    print(rezultat)