def rs(mat, n):
    s = 0
    p0 = (0, 0)
    p_vre = mat[0][0]
    while p0[1] < n:
        if p0[0] == 0:
            p1 = (1, p0[1])
        else:
            p1 = (0, p0[1] + 1)
            if p1[1] == n:
                break        
        t_vre = mat[p1[0]][p1[1]]
        if p_vre % 2 == t_vre % 2:
            s += 1
        p_vre = t_vre
        p0 = p1   
    return s
t = int(input())
for _ in range(t):
    n = int(input())
    red1 = list(map(int, input().split()))
    red2 = list(map(int, input().split()))
    ms = 0
    kombinacije = 2 ** n
    for i in range(kombinacije):
        z = [red1[:], red2[:]]
        zamene = []
        tr = i
        for j in range(n):
            if tr > 0:
                if tr % 2 == 1:
                    zamene.append(j)
                tr //= 2
        for q in zamene:
            z[0][q], z[1][q] = z[1][q], z[0][q]   
        ts = rs(z, n)
        ms = max(ms, ts) 
    print(ms)