N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

p = 0
for i in range(N):
    p += B[A[i] - 1]
    print("ba", B[A[i] - 1])
    if i > 0 and A[i] - 1 == A[i - 1]:
        p += C[A[i - 1] - 1]
        print("c", C[A[i - 1] - 1])
print(p)