047:校园食宿预订系统
python">n,m=map(int,input().split())
num={}
price={}
for i in range(m):na,pr,nu=map(str,input().split())num[na]=int(nu)price[na]=int(pr)
sum=0
for j in range(n):lis=list(map(str,input().split()))for i in lis:if num[i]>0:num[i]=num[i]-1sum+=price[i]
print(sum)