import copy


t = int(input())
res = []
m = []
br = 0

for i in range(t):
    m = []
    n = int(input())

    l1 = list(map(int, input().split()))
    l2 = list(map(int, input().split()))
    m.append(l1)
    m.append(l2)
    

    
    k = [False] * n
    
    
    if sum(l1)+sum(l2) == 2*n:
        res.append(n*2-1)
        
    
    elif n == 2:
        for i in range(2):
            for j in range(n):
                if i == 0:
                    if m[0][j] % 2 == m[1][j] % 2:
                        br += 1
                        k[j] = True
                else:
                    if j < n-1 and m[1][j] % 2 == m[0][j+1] % 2:
                        br += 1
    
        m0 = copy.deepcopy(m)
        m1 = copy.deepcopy(m)
        
        br0 = br
        br1 = br
        
        if not k[0]:
            temp = m0[0][0]
            m0[0][0] = m0[1][0]
            m0[1][0] = temp
            
        if m0[1][0] % 2 == m0[0][1] % 2:
            br0 = br + 1
        
    
        
        if not k[1]:
            temp = m1[0][1]
            m1[0][1] = m1[1][1]
            m1[1][1] = temp
    
        if m1[1][0] % 2 == m1[0][1] % 2:
            br1 = br + 1
        br = max(br0, br1)
        
        res.append(br)
        
for i in range(t):
    print(res[i])
        
    
    
    
    #elif n == 3: