m=[]
sreca=0
t=int(input())
for i in range(t):
    n=int(input())
            
    a=[]
    for j in range(2):      
        a.append(list(map(int, input().split())))
    m.append(a)


l=len(m)
#ulaz dobar
for i in range(t - 2):  
    b = m[i]    
    c = m[i + 1]  

    
    for x in range(2):  
        for y in range(len(b[x])):  
            if b[x][y] == c[x][y] or (b[x][y] % 2 == 1 and c[x][y] % 2 == 1):
                sreca += 1  # Increment `sreca` if the condition is met


print(sreca)