from itertools import product
def par(x):
    return x % 2
def cal(mat):
    N = len(mat[0])
    hap = 0
    prev = mat[0][0]  
    for j in range(1, N):
        p_val = [mat[0][j], mat[1][j]]
        
        for val in p_val:
            if par(val) == par(prev):
                hap += 1
            prev = val  
    return hap
def max_hap(mat):
    N = len(mat[0])
    max_h = cal(mat)   
    sw_combs = product([False, True], repeat=N)   
    for sw_comb in sw_combs:
        temp_mat = [row[:] for row in mat]        
        for i in range(N):
            if sw_comb[i]:
                temp_mat[0][i], temp_mat[1][i] = temp_mat[1][i], temp_mat[0][i]       
        hap = cal(temp_mat)       
        max_h = max(max_h, hap)   
    return max_h
def proc():
    t = int(input())    
    for i in range(t):
        n = int(input())
        mat = []       
        for j in range(2):
            row = list(map(int, input().split()))
            mat.append(row)       
        res = max_hap(mat)       
        if i > 0:
            res += 1
       
        print(res)
proc()