import copy

def ispitaj(mm):
    br = 0
    for j in range(n):
        
        if mm[0][j] % 2 == mm[1][j] % 2:
            br += 1
            k[j] = True
        
        if j < n-1 and mm[1][j] % 2 == mm[0][j+1] % 2:
            br += 1
    return(br)                

def okreni(kol): 
    if not k[kol]:
            temp = m0[0][kol]
            m0[0][kol] = m0[1][kol]
            m0[1][kol] = temp


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

for i in range(t):
    m = []
    br = 0
    n = int(input())
    # n=3

    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)
    

    
    elif n == 3:
        
        br=ispitaj(m)
        re = br
        for i in range(n):
            br0=0
            m0 = copy.deepcopy(m)
            okreni(i)
            br0 = ispitaj(m0)
            re=max(re,br0)
        
        br0=0
        m0 = copy.deepcopy(m)
        okreni(0)
        okreni(1)
        br0 = ispitaj(m0)
        re=max(re,br0)
            
        br0=0
        m0 = copy.deepcopy(m)
        okreni(0)
        okreni(2)
        br0 = ispitaj(m0)
        re=max(re,br0)
        
        br0=0
        m0 = copy.deepcopy(m)
        okreni(1)
        okreni(2)
        br0 = ispitaj(m0)
        re=max(re,br0)
        
        br0=0
        m0 = copy.deepcopy(m)
        okreni(0)
        okreni(1)
        okreni(2)
        br0 = ispitaj(m0)
        re=max(re,br0)
        
        res.append(re)
    
    else:
        br=ispitaj(m)
        re = br
        
        for i in range(n):
            br0=0
            m0 = copy.deepcopy(m)
            okreni(i)
            br0 = ispitaj(m0)
            re=max(re,br0)
        
        for i in range(n-1):
            for j in range(i+1, n):
                br0=0
                m0 = copy.deepcopy(m)
                okreni(i)
                okreni(j)
                br0 = ispitaj(m0)
                re=max(re,br0)
        
        for i in range(n-2):
            for j in range(i+1, n-1):
                for q in range(j+1, n):
                    br0=0
                    m0 = copy.deepcopy(m)
                    okreni(i)
                    okreni(j)
                    okreni(q)
                    br0 = ispitaj(m0)
                    re=max(re,br0) 
        
        for i in range(n-3):
            for j in range(i+1, n-2):
                for q in range(j+1, n-1):
                    for w in range(q+1, n):
                        br0=0
                        m0 = copy.deepcopy(m)
                        okreni(i)
                        okreni(j)
                        okreni(q)
                        okreni(w)
                        br0 = ispitaj(m0)
                        re=max(re,br0)
                        
        for i in range(n-4):
            for j in range(i+1, n-3):
                for q in range(j+1, n-2):
                    for w in range(q+1, n-1):
                        for p in range(w+1, n):
                            br0=0
                            m0 = copy.deepcopy(m)
                            okreni(i)
                            okreni(j)
                            okreni(q)
                            okreni(w)
                            okreni(p)
                            br0 = ispitaj(m0)
                            re=max(re,br0)
        
        for i in range(n-5):
            for j in range(i+1, n-4):
                for q in range(j+1, n-3):
                    for w in range(q+1, n-2):
                        for p in range(w+1, n-1):
                            for g in range(p+1, n):
                                br0=0
                                m0 = copy.deepcopy(m)
                                okreni(i)
                                okreni(j)
                                okreni(q)
                                okreni(w)
                                okreni(p)
                                okreni(g)
                                br0 = ispitaj(m0)
                                re=max(re,br0)
        
        for i in range(n-6):
            for j in range(i+1, n-5):
                for q in range(j+1, n-4):
                    for w in range(q+1, n-3):
                        for p in range(w+1, n-2):
                            for g in range(p+1, n-1):
                                for h in range(g+1, n):
                                    br0=0
                                    m0 = copy.deepcopy(m)
                                    okreni(i)
                                    okreni(j)
                                    okreni(q)
                                    okreni(w)
                                    okreni(p)
                                    okreni(g)
                                    okreni(h)
                                    br0 = ispitaj(m0)
                                    re=max(re,br0)
                                
        for i in range(n-7):
            for j in range(i+1, n-6):
                for q in range(j+1, n-5):
                    for w in range(q+1, n-4):
                        for p in range(w+1, n-3):
                            for g in range(p+1, n-2):
                                for h in range(g+1, n-1):
                                    for ii in range(h+1, n):
                                        br0=0
                                        m0 = copy.deepcopy(m)
                                        okreni(i)
                                        okreni(j)
                                        okreni(q)
                                        okreni(w)
                                        okreni(p)
                                        okreni(g)
                                        okreni(h)
                                        okreni(ii)
                                        br0 = ispitaj(m0)
                                        re=max(re,br0)
        
        for i in range(n-8):
            for j in range(i+1, n-7):
                for q in range(j+1, n-6):
                    for w in range(q+1, n-5):
                        for p in range(w+1, n-4):
                            for g in range(p+1, n-3):
                                for h in range(g+1, n-2):
                                    for ii in range(h+1, n-1):
                                        for jj in range(ii+1, n):
                                            br0=0
                                            m0 = copy.deepcopy(m)
                                            okreni(i)
                                            okreni(j)
                                            okreni(q)
                                            okreni(w)
                                            okreni(p)
                                            okreni(g)
                                            okreni(h)
                                            okreni(ii)
                                            okreni(jj)
                                            br0 = ispitaj(m0)
                                            re=max(re,br0)
                                            
        for i in range(n-9):
            for j in range(i+1, n-8):
                for q in range(j+1, n-7):
                    for w in range(q+1, n-6):
                        for p in range(w+1, n-5):
                            for g in range(p+1, n-4):
                                for h in range(g+1, n-3):
                                    for ii in range(h+1, n-2):
                                        for jj in range(ii+1, n-1):
                                            for qq in range(jj+1, n):
                                                br0=0
                                                m0 = copy.deepcopy(m)
                                                okreni(i)
                                                okreni(j)
                                                okreni(q)
                                                okreni(w)
                                                okreni(p)
                                                okreni(g)
                                                okreni(h)
                                                okreni(ii)
                                                okreni(jj)
                                                okreni(qq)
                                                br0 = ispitaj(m0)
                                                re=max(re,br0)
        
        
        
        
        res.append(re)
    


for i in range(t):
    print(res[i])