# -*- coding: utf-8 -*-

N = raw_input()
ans = 0

a = []
b = []
c = []
for i in range(N):
    a.append(map(int, raw_input().split()))
for i in range(N):
    b.append(map(int, raw_input().split()))
for i in range(N):
    c.append(map(int, raw_input().split()))
    
for i in range(N-1)
	if a[N] - a[N+1] == 1
  		ans += c[N]
ans += sum(b)

print(ans)
      
