import copy

def combs(a):
    if len(a) == 0:
        return [[]]
    cs = []
    for c in combs(a[1:]):
        cs += [c, c+[a[0]]]
    return cs

#print(combs('1000000000 1000000000 999999999 999999999 1000000000 1000000000 999999999 999999999 1000000000 1000000000 999999999 999999999'.split()))

for i in range(int(input().strip())):
    n = int(input().strip())

    matrix = [
        [int(x) for x in input().strip().split(' ')],
        [int(x) for x in input().strip().split(' ')]
    ]

    moves = []

    for prev_column in range(len(matrix[0]) - 1):
        next_column = prev_column + 1

        if matrix[1][prev_column] % 2 != matrix[0][next_column]:
            #if prev_column == 2:
            #    print(matrix[0][prev_column] % 2)
            #    print(matrix[1][next_column] % 2)
            #    print(matrix[0][prev_column] % 2 == matrix[1][next_column])
                
            if matrix[0][prev_column] % 2 == matrix[0][next_column] % 2:
                l = prev_column

                if l not in moves:
                    moves.append(l)
            if matrix[1][prev_column] % 2 == matrix[1][next_column] % 2:
                l = next_column

                if l not in moves:
                    moves.append(l)
            
            #if matrix[0][prev_column] % 2 == matrix[1][next_column] % 2:
                #print('s')
            #    l = [prev_column, next_column]
            #
            #    if l not in moves and reversed(l) not in moves:
            #        moves.append(prev_column)
            #        moves.append(next_column)

    moves = combs(moves)
    srecas = []

    for move in moves:
        #print(move)
        test = copy.deepcopy(matrix)

        did_moves = []

        for moved_column in move:
            #print(moved_column)
            if moved_column not in did_moves:
                did_moves.append(moved_column)

                first = test[0][moved_column]
                second = test[1][moved_column]
                
                test[1][moved_column] = first
                test[0][moved_column] = second

        #print(test)

        perica = [0, 0]
        sreca = 0

        for cell in range(2 * len(test[0]) - 1):
            if perica[0] == 0:
                perica[0] = 1

                if test[0][perica[1]] % 2 == test[1][perica[1]] % 2:
                    sreca += 1
            else:
                perica = [0, perica[1] + 1]

                if test[1][perica[1] - 1] % 2 == test[0][perica[1]] % 2:
                    sreca += 1
            
        #print(perica)
        srecas.append(sreca)

    print(max(srecas))
#import os, psutil; print(psutil.Process(os.getpid()).memory_info().rss / 1024 ** 2)