A. New Scheme
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
s = list(map(int, input().rstrip('\n').split()))
for i in range(len(s)):
if i != 0:
if s[i] < s[i-1]:
print("No")
exit()
if s[i] % 25 != 0:
print("No")
exit()
if s[i] < 100 or 675 < s[i]:
print("No")
exit()
print("Yes")
if __name__ == '__main__':
solve()
B. Default Price
import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, m = list(map(int, input().rstrip('\n').split()))
c = list(map(str, input().rstrip('\n').split()))
d = list(map(str, input().rstrip('\n').split()))
p = list(map(int, input().rstrip('\n').split()))
dt = collections.defaultdict(int)
for i in range(m):
dt[d[i]] = p[i + 1]
ans = 0
for i in range(n):
if c[i] not in dt:
ans += p[0]
else:
ans += dt[c[i]]
print(ans)
if __name__ == '__main__':
solve()