T = int(input())

N = list()
matrices = list()

for test in range(T):
    N.append(int(input()))

    matrix = list()
    matrix.append(list(map(int, input().split())))
    matrix.append(list(map(int, input().split())))

    matrices.append(matrix)

happiness = 0
happiness1 = 0

for index in range(len(matrices)):
    matrix = matrices[index]

    n = N[index]

    for col in range(n - 1):
        
        upper = matrix[0][col]
        lower = matrix[1][col]

        if upper % 2 == lower % 2:
            happiness += 1

        next_upper = matrix[0][col + 1]
        next_lower = matrix[1][col + 1]
        
        if col == n-2 and (next_upper % 2 == next_lower % 2):
            happiness+=1
            tmp = next_upper
            matrix[0][col+1] = next_lower
            matrix[1][col+1] = tmp
        if lower % 2 == next_upper % 2:
            happiness += 1
        elif upper % 2 == next_upper % 2 and not upper %2 == matrix[1][col -1]%2:
            happiness += 1
            tmp = upper
            matrix[0][col] = lower
            matrix[1][col] = tmp
        elif upper % 2 == next_lower % 2 and not upper %2 == matrix[1][col -1]%2:
            happiness += 1
            tmp = upper
            matrix[0][col] = lower
            matrix[1][col] = tmp
            tmp = next_upper
            matrix[0][col+1] = next_lower
            matrix[1][col+1] = tmp
        elif lower %2 == next_lower%2:
            happiness+=1
            tmp = next_upper
            matrix[0][col+1] = next_lower
            matrix[1][col+1] = tmp


    print(happiness)

    happiness = 0