64_2_PCG_06

Max Score = 100


# 0001, 2022-02-24 08:07:31, xx (0%)

a=[]
sum=0
k=0
while k==0:
  s=[input().split()]
  if s==[q]: k+=1
  else : a+=[s]
b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0002, 2022-02-24 08:07:51, xx (0%)

a=[]
sum=0
k=0
while k==0:
  s=[input().split()]
  if s==['q']: k+=1
  else : a+=[s]
b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0003, 2022-02-24 08:09:05, -- (0%)

a=[]
sum=0
k=0
while k==0:
  s=[input().split()]
  if s==[['q']]: k+=1
  else : a+=[s]
b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0004, 2022-02-24 08:09:53, -- (0%)

a=[]
sum=0
k=0
while k==0:
  s=input().split()
  if s==['q']: k+=1
  else : a+=[s]
  print(s,a)
b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0005, 2022-02-24 08:10:27, -- (0%)

a=[]
sum=0
k=0
while k==0:
  s=input()
  if s=='q': k+=1
  else : a+=[s.split()]
b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0006, 2022-02-24 08:11:47, -- (0%)

a=[]
sum=0
k=0
while k==0:
  s=input()
  if s=='q': k+=1
  else : a+=[s.split()]

b=[input().split()]
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0007, 2022-02-24 08:14:16, -- (0%)

a=[]
sum=0.0
k=0
while k==0:
  s=input()
  if s=='q': k+=1
  else : a+=[s.split()]

b=input().split()
print(b)
for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0008, 2022-02-24 08:15:05, PP (100%)

a=[]
sum=0.0
k=0
while k==0:
  s=input()
  if s=='q': k+=1
  else : a+=[s.split()]

b=input().split()

for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)
# 0009, 2022-02-24 08:15:20, PP (100%)

a=[]
sum=0.0
k=0
while k==0:
  s=input()
  if s=='q': k+=1
  else : a+=[s.split()]

b=input().split()

for i in range(len(b)):
  for k in range(len(a)):
    if b[i]==a[k][0]: sum+=float(a[k][1])
print('total payment',sum)

# 0010, 2022-02-24 08:08:34, xx (0%)

list_product=[]
k=input().split()
while k!='q':
    list_product.append(k)
    k=input().split()

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] or d in e[0]:
            totals+=float(e[1])
print('total payment',totals)            
# 0011, 2022-02-24 08:08:52, xx (0%)

list_product=[]
k=input().split()
while k!='q':
    list_product.append(k)
    k=input().split()

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] or d in e[0]:
            totals+=float(e[1])
print('total payment',totals)            
# 0012, 2022-02-24 08:13:25, PP (100%)

list_product=[]
k=input().split()
while k!='[q]':
    list_product.append(k)
    k=input().split()
    if k==['q']:
        break

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] or d in e[0]:
            totals+=float(e[1])

print('total payment',totals)            
# 0013, 2022-02-24 08:13:43, PP (100%)

list_product=[]
k=input().split()
while k!='[q]':
    list_product.append(k)
    k=input().split()
    if k==['q']:
        break

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] or d in e[0]:
            totals+=float(e[1])

print('total payment',totals)
# 0014, 2022-02-24 08:15:39, xx (0%)

list_product=[]
k=input().split()
while k!='[q]':
    list_product.append(k)
    k=input().split()
   

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] :
            totals+=float(e[1])

print('total payment',totals)            
# 0015, 2022-02-24 08:15:50, xx (0%)

list_product=[]
k=input().split()
while k!='[q]':
    list_product.append(k)
    k=input().split()
   

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] :
            totals+=float(e[1])

print('total payment',totals)
# 0016, 2022-02-24 08:16:55, xx (0%)

list_product=[]
k=input().split()
while k!='[q]':
    list_product.append(k)
    k=input().split()
   

products=input().split()
totals = 0

for d in products:
    for e in list_product:
        if d==e[0] or d in e[0] :
            totals+=float(e[1])

print('total payment',totals)            

# 0017, 2022-02-24 08:11:27, compilation error (0%)

n=[]
p=[]
while True:
    x=input()
    if x=q: break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    if s[i] in n:
# 0018, 2022-02-24 08:13:36, compilation error (0%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x=q: break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=p[j]

print('total payment',price)
# 0019, 2022-02-24 08:14:13, xx (0%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x==q: break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=p[j]

print('total payment',price)
# 0020, 2022-02-24 08:14:29, xx (0%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x==str(q): break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=p[j]

print('total payment',price)
# 0021, 2022-02-24 08:15:04, PP (100%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x=='q': break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=float(p[j])

print('total payment',price)
# 0022, 2022-02-24 08:15:17, PP (100%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x=='q': break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=float(p[j])

print('total payment',price)
# 0023, 2022-02-24 08:15:40, PP (100%)

n=[]
p=[]
price=0
while True:
    x=input()
    if x=='q': break
    x=x.split()
    n.append(x[0]) ; p.append(x[1])
s=input().split()
for i in range (len(s)):
    for j in range(len(n)):
        if s[i]==n[j]:
            price+=float(p[j])

print('total payment',price)

# 0024, 2022-02-24 08:04:34, TT (0%)

wack = input()
while wack != 'q':
    sinka ,price = wack.split()
    
whattobuy  = input().split()
where = 0
summary = 0
intprice = 0
for i in whattobuy:
    where = sinka.index(i)
    intprice = price[where]
    intprice = int(intprice)
    summary += intprice
    
print('total payment {}'.format(summary))

# 0025, 2022-02-24 08:06:14, xx (0%)

wack = input()
while wack != 'q':
    sinka ,price = wack.split()
    wack = input()
    
whattobuy  = input().split()
where = 0
summary = 0
intprice = 0
for i in whattobuy:
    where = sinka.index(i)
    intprice = price[where]
    intprice = int(intprice)
    summary += intprice
    
print('total payment {}'.format(summary))

# 0026, 2022-02-24 08:07:01, xx (0%)

wack = input()
while wack != 'q':
    sinka ,price = wack.split()
    wack = input()
    
whattobuy  = input().split()
where = 0
summary = 0
floatprice = 0
for i in whattobuy:
    where = sinka.index(i)
    floatprice = price[where]
    floatprice = float(floatprice)
    summary += intprice
    
print('total payment {}'.format(summary))

# 0027, 2022-02-24 08:08:20, compilation error (0%)

wack = input()
sinka = list()
price = []
while wack != 'q':
    sinka ,price += wack.split()
    wack = input()
    
whattobuy  = input().split()
where = 0
summary = 0
floatprice = 0
for i in whattobuy:
    where = sinka.index(i)
    floatprice = price[where]
    floatprice = float(floatprice)
    summary += floatprice
    
print('total payment {}'.format(summary))

# 0028, 2022-02-24 08:09:18, xx (0%)

wack = input()
sinka = list()
price = []
lol = ''
bruh = ''
while wack != 'q':
    lol , bruh = wack.split()
    sinka += lol
    price += bruh
    wack = input()
    
whattobuy  = input().split()
where = 0
summary = 0
floatprice = 0
for i in whattobuy:
    where = sinka.index(i)
    floatprice = price[where]
    floatprice = float(floatprice)
    summary += floatprice
    
print('total payment {}'.format(summary))

# 0029, 2022-02-24 08:10:45, PP (100%)

wack = input()
sinka = list()
price = []
lol = ''
bruh = ''
while wack != 'q':
    lol , bruh = wack.split()
    sinka.append(lol)
    price.append(bruh)
    wack = input()
    
whattobuy  = input().split()
where = 0
summary = 0
floatprice = 0
for i in whattobuy:
    where = sinka.index(i)
    floatprice = price[where]
    floatprice = float(floatprice)
    summary += floatprice
    
print('total payment {}'.format(summary))


# 0030, 2022-02-24 08:11:39, xx (0%)

a = input()
x = []
price = 0
while a != 'q' :
    a.split()
    x.append(list(a))
    a = input()
b = input().split()
for e in b:
    j = x.index(e)
    price += int(x[j][1])
print('totalpayment' + price)
    
# 0031, 2022-02-24 08:12:24, xx (0%)

a = input()
x = []
price = 0
while a != 'q' :
    a.split()
    x.append(list(a))
    a = input()
b = input().split()
for e in b:
    j = x.index(e)
    price += int(x[j+1])
print('totalpayment' + price)
    
# 0032, 2022-02-24 08:13:36, xx (0%)

a = input()
x = []
price = 0
while a != 'q' :
    k = a.split()
    x.append(list(k))
    a = input()
b = input().split()
for e in b:
    j = x.index(e)
    price += int(x[j+1])
print('totalpayment' + price)
# 0033, 2022-02-24 08:14:08, xx (0%)

a = input()
x = []
price = 0
while a != 'q' :
    k = a.split()
    x.append(list(k))
    a = input()
b = input().split()
for e in b:
    j = x.index(e)
    price += float(x[j+1])
print('total payment' + price)
# 0034, 2022-02-24 08:14:35, xx (0%)

a = input()
x = []
price = 0
while a != 'q' :
    k = a.split()
    x.append(list(k))
    a = input()
b = input().split()
for e in b:
    j = x.index(e)
    price += float(x[j][1])
print('total payment' + price)
# 0035, 2022-02-24 08:15:06, PP (100%)

a = input()
x = []
price = 0
while a != 'q' :
    y=a.split()
    x.append(y)
    a = input()
b = input().split()
for e in b:
    for j in range(len(x)):
        if(e==x[j][0]):
            price+=float(x[j][1])
print('total payment',price)

# 0036, 2022-02-24 08:03:41, xx (0%)

list1 = []
list2 = []
while True :
    input = input().split()
    if input == ['q'] :
        break
    list1.append(input[0])
    list2.append(int(input[1]))

q = input().split()

c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))
# 0037, 2022-02-24 08:05:16, xx (0%)

list1 = []
list2 = []
while True :
    p = input().split()
    if input == ['q'] :
        break
    list1.append(p[0])
    list2.append(float(p[1]))

q = input().split()

c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))
# 0038, 2022-02-24 08:05:43, PP (100%)

list1 = []
list2 = []
while True :
    p = input().split()
    if p == ['q'] :
        break
    list1.append(p[0])
    list2.append(float(p[1]))

q = input().split()

c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))
# 0039, 2022-02-24 08:06:32, PP (100%)

list1 = [] ; list2 = []
while True :
    p = input().split()
    if p == ['q'] : break
    list1.append(p[0])
    list2.append(float(p[1]))

q = input().split() ; c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))
# 0040, 2022-02-24 08:09:21, PP (100%)

list1 = [] ; list2 = []
while True :
    try :
        p = input().split()
        list1.append(p[0])
        list2.append(float(p[1]))
    except : break

q = input().split() ; c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))
# 0041, 2022-02-24 08:10:00, PP (100%)

list1 = [] ; list2 = []
while True :
    p = input().split()
    if p == ['q'] : break
    list1.append(p[0])
    list2.append(float(p[1]))

q = input().split() ; c = 0

for _ in q :
    c += list2[list1.index(_)]
    
print('total payment {}'.format(c))

# 0042, 2022-02-24 08:08:02, TT (0%)

x = input().split()
d={}
while x[0]!='q':
    if x[0] in d:
        d[x[0]] += x[1]
    else:
        d[x[0]] = x[1]
    
total=input().split()
summ=0
for e in total:
    summ+=d[3]
print("total payment",summ)
# 0043, 2022-02-24 08:08:31, TT (0%)

x = input().split()
d={}
while x[0]!='q':
    if x[0] in d:
        d[x[0]] += x[1]
    else:
        d[x[0]] = x[1]
    
total=input().split()
summ=0
for e in total:
    summ+=d[1]
print("total payment",summ)
# 0044, 2022-02-24 08:09:21, TT (0%)

x = input().split()
d={}
while x[0]!='q':
    if x[0] in d:
        d[x[0]] += x[1]
    else:
        d[x[0]] = x[1]
    
total=input().split()
summ=0
for e in total:
    summ+=d[e]
print("total payment",summ)
# 0045, 2022-02-24 08:10:39, xx (0%)

namelist= []
pricelist = []
a = float(input())
sell = 0
while a != 'q' :
    name,price = a.split()
    namelist.append(name)
    pricelist.append(price)
    a = float(input())
order = input().split()
for i in range(len(order)) :
    j = namelist.index(order[i])
    k = pricelist.index(pricelist[j])
    sell += pricelist[k]
print('total payment'+' '+sell)
# 0046, 2022-02-24 08:11:10, PP (100%)

x = input().split()
d={}
while x[0]!='q':
    if x[0] in d:
        d[x[0]] += float(x[1])
    else:
        d[x[0]] = float(x[1])
    x=input().split()
    
total=input().split()
summ=0
for e in total:
    summ+=d[e]
print("total payment",summ)

# 0047, 2022-02-24 08:12:54, xx (0%)

YUI = input()
KOA = []
total = 0

while YUI != "q":
    KOA.append(ABC.split())
    YUI = input()
for want in input().split():
    for e in KOA:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0048, 2022-02-24 08:13:16, PP (100%)

ABC = input()
XYZ = []
total = 0

while ABC != "q":
    XYZ.append(ABC.split())
    ABC = input()
for want in input().split():
    for e in XYZ:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0049, 2022-02-24 08:16:21, PP (100%)

frt = input()
scd = []
total = 0

while frt != "q":
    scd.append(frt.split())
    frt = input()
for want in input().split():
    for e in scd:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0050, 2022-02-24 08:16:43, compilation error (0%)

frt = input()

scd = []

total = 0

 while frt != "q":
    scd.append(frt.split())
    frt = input()
 for want in input().split():
    for e in scd:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0051, 2022-02-24 08:16:59, compilation error (0%)

frt = input()
scd = []
total = 0

 while frt != "q":
    scd.append(frt.split())
    frt = input()
 for want in input().split():
    for e in scd:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)

# 0052, 2022-02-24 08:11:11, xx (0%)

pro = []
price=[]
x = input()
while x!=q:
  pro.append(x[0])
  price.append(float(x[1]))
  x= input(x)


Allprice=0
want=input().split()

for e in want:
  i = pro.index(e)
  Allprice += price(i)

print('total payment '+Allprice)
  

# 0053, 2022-02-24 08:11:41, xx (0%)

pro = []
price=[]
x = input()
while x!='q':
  pro.append(x[0])
  price.append(float(x[1]))
  x= input(x)


Allprice=0
want=input().split()

for e in want:
  i = pro.index(e)
  Allprice += price(i)

print('total payment '+Allprice)
# 0054, 2022-02-24 08:12:27, xx (0%)

pro = []
price=[]
x = input()
while x!='q':
  x = x.split()
  pro.append(x[0])
  price.append(float(x[1]))
  x= input(x)


Allprice=0
want=input().split()

for e in want:
  i = pro.index(e)
  Allprice += price(i)

print('total payment '+Allprice)
# 0055, 2022-02-24 08:13:43, PP (100%)

i1 = []
i2 = []
n = input().split()

while n[0] != 'q':
    i1.append(n[0])
    i2.append(n[1])
    n = input().split()
item = input().split()

tt = 0
for e in range(len(item)):
    o = item[e]
    oo=i1.index(o)
    tt += float(i2[oo])

print('total payment',tt)
# 0056, 2022-02-24 08:15:12, PP (100%)

pro = []
price = []
n = input().split()

while n[0] != 'q':
    pro.append(n[0])
    price.append(n[1])
    n = input().split()
item = input().split()

tt = 0
for e in range(len(item)):
    o = item[e]
    oo=pro.index(o)
    tt += float(price[oo])

print('total payment',tt)

# 0057, 2022-02-24 08:11:23, xx (0%)

M=[]
m=0
while m!='q':
    m=input()
    k=m.split()
    M.append(k)
    
p=input().split()

price=0
for e in p:
    for i in range(M):
        if e==M[i][0]:
            price+=int(M[i][1])
    
print('total payment'+str(price))    


# 0058, 2022-02-24 08:12:47, xx (0%)

M=[]
m=0
while m!='q':
    m=input()
    k=m.split()
    M.append(k)
    
p=input().split()

price=0
for e in p:
    for i in range(len(M)):
        if e==M[i][0]:
            price+=int(M[i][1])
    
print('total payment'+str(price))
# 0059, 2022-02-24 08:14:29, -- (0%)

M=[]
m=0
while m!='q':
    m=input()
    k=m.split()
    M.append(k)
    
p=input().split()

price=0
for e in p:
    for i in range(len(M)):
        if e==M[i][0]:
            price+=float(M[i][1])
    
print('total payment'+str(price))    

# 0060, 2022-02-24 08:14:38, -- (0%)

M=[]
m=0
while m!='q':
    m=input()
    k=m.split()
    M.append(k)
    
p=input().split()

price=0
for e in p:
    for i in range(len(M)):
        if e==M[i][0]:
            price+=float(M[i][1])
    
print('total payment'+str(price))
# 0061, 2022-02-24 08:15:03, PP (100%)

M=[]
m=0
while m!='q':
    m=input()
    k=m.split()
    M.append(k)
    
p=input().split()

price=0
for e in p:
    for i in range(len(M)):
        if e==M[i][0]:
            price+=float(M[i][1])
    
print('total payment'+' '+str(price))    




# 0062, 2022-02-24 08:10:46, -x (0%)

x = input()
l = []
p = []
while x != "q":
  x = x.split()
  l.append(x[0])
  p.append(x[1])
  x = input()
xx = input().split()
k = []

for i in range(len(xx)):
  k.append(l.index(xx[i]))
price = 0
for i in range(len(k)):
  price += float(p[i])


print("total",price)
print(k)

# 0063, 2022-02-24 08:11:15, -x (0%)

x = input()
l = []
p = []
while x != "q":
  x = x.split()
  l.append(x[0])
  p.append(x[1])
  x = input()
xx = input().split()
k = []

for i in range(len(xx)):
  k.append(l.index(xx[i]))
price = 0
for i in range(len(k)):
  price += float(p[i])


print("total",price)
# 0064, 2022-02-24 08:13:44, -x (0%)

x = input()
l = []
p = []
while x != "q":
  x = x.split()
  l.append(x[0])
  p.append(x[1])
  x = input()
xx = input().split()
k = []
for i in range(len(xx)):
  k.append(l.index(xx[i]))
price = 0
for i in range(len(k)):
  price += float(p[i])


print("total payment",price)
# 0065, 2022-02-24 08:13:50, -x (0%)

x = input()
l = []
p = []
while x != "q":
  x = x.split()
  l.append(x[0])
  p.append(x[1])
  x = input()
xx = input().split()
k = []
for i in range(len(xx)):
  k.append(l.index(xx[i]))
price = 0
for i in range(len(k)):
  price += float(p[i])


print("total payment ",price)
# 0066, 2022-02-24 08:15:04, PP (100%)

x = input()
l = []
p = []
while x != "q":
  x = x.split()
  l.append(x[0])
  p.append(x[1])
  x = input()
xx = input().split()
k = []
for i in range(len(xx)):
  k.append(l.index(xx[i]))
price = 0
for i in k:
  price += float(p[i])


print("total payment",price)

# 0067, 2022-02-24 08:11:43, xx (0%)

data = input().split()
name = list()
price = list()
while data != 'q' :
    n,p = data.split()
    name.append(n)
    price.append(p)
    data = input().split()
c = input().split()
p = 0
for i in range(len(c)) :
    d = name.index(c[i])
    if d != -1 :
        p += price[d]
print('total payment',p)
# 0068, 2022-02-24 08:12:15, xx (0%)

data = input().split()
name = list()
price = list()
while data != 'q' :
    n,p = data.split()
    name.append(n)
    price.append(p)
    data = input().split()
c = input().split()
p = 0
for i in range(len(c)) :
    d = name.index(c[i])
    if d != -1 :
        p += float(price[d])
print('total payment',p)
# 0069, 2022-02-24 08:13:38, xx (0%)

data = input().split()
name = list()
price = list()
while data != 'q' :
    n,p = data.split()
    name.append(n)
    price.append(p)
    data = input().split()
c = input().split()
p = 0
for i in range(len(c)) :
    if c[i] in name :
        d = name.index(c[i])
    p += float(price[d])
print('total payment',p)
# 0070, 2022-02-24 08:15:28, xx (0%)

data = input()
name = list()
price = list()
while data != 'q' :
    n,p = data.split()
    name.append(n)
    price.append(p)
    data = input().split()
c = input().split()
p = 0
for i in range(len(c)) :
    if c[i] in name :
        d = name.index(c[i])
    p += float(price[d])
print('total payment',p)
# 0071, 2022-02-24 08:16:07, PP (100%)

data = input()
name = list()
price = list()
while data != 'q' :
    n,p = data.split()
    name.append(n)
    price.append(p)
    data = input()
c = input().split()
p = 0
for i in range(len(c)) :
    if c[i] in name :
        d = name.index(c[i])
    p += float(price[d])
print('total payment',p)

# 0072, 2022-02-24 08:06:28, xx (0%)

inp=input()
name=[]
price=[]
while inp != q:
    inp.split()
    name.append(inp[0])
    price.append(float(inp[2]))
    inp=input()
buy=input().split()
total=0
for e in buy:
    k=name.index(e)
    total+=price[k]
print('total payment',total)
    
# 0073, 2022-02-24 08:07:16, xx (0%)

inp=input()
name=[]
price=[]
while inp != 'q':
    inp.split()
    name.append(inp[0])
    price.append(float(inp[2]))
    inp=input()
buy=input().split()
total=0
for e in buy:
    k=name.index(e)
    total+=price[k]
print('total payment',total)
# 0074, 2022-02-24 08:07:21, xx (0%)

inp=input()
name=[]
price=[]
while inp != 'q':
    inp.split()
    name.append(inp[0])
    price.append(float(inp[2]))
    inp=input()
buy=input().split()
total=0
for e in buy:
    k=name.index(e)
    total+=price[k]
print('total payment',total)
# 0075, 2022-02-24 08:07:52, xx (0%)

inp=input()
name=[]
price=[]
while inp != 'q':
    inp.split()
    name.append(inp[0])
    price.append(float(inp[1]))
    inp=input()
buy=input().split()
total=0
for e in buy:
    k=name.index(e)
    total+=price[k]
print('total payment',total)
# 0076, 2022-02-24 08:09:45, PP (100%)

inp=input()
name=[]
price=[]
while inp != 'q':
    inp=inp.split()
    name.append(inp[0])
    price.append(float(inp[1]))
    inp=input()
buy=input().split()
total=0
for e in buy:
    k=name.index(e)
    total+=price[k]
print('total payment',total)

# 0077, 2022-02-24 08:11:25, -x (0%)

d = []
c = []
e = input().split()
while e[0] != 'q':
    d += [e[0]]
    c += [e[1]]
    e = input().split()
x = input().split()
s = 0
for i in range(len(x)):
    if x[i] in d:
        s += float(c[i])
print('total patment'+' '+str(s))

# 0078, 2022-02-24 08:12:51, -x (0%)

d = []
c = []
e = input().split()
while e[0] != 'q':
    d += [e[0]]
    c += [e[1]]
    e = input().split()
x = input().split()
s = 0
for i in range(len(x)):
    if x[i] in d:
        s += float(c[i])
print('total patment'+' '+str(s))

# 0079, 2022-02-24 08:16:04, -- (0%)

d = []
c = []
e = input().split()
while e[0] != 'q':
    d += [e[0]]
    c += [e[1]]
    e = input().split()
x = input().split()
s = 0
for i in range(len(x)):
    if x[i] in d:
        r = d.index(x[i])
        s += float(c[r])
print('total patment'+' '+str(s))

# 0080, 2022-02-24 08:16:48, -- (0%)

d = []
c = []
e = input().split()
while e[0] != 'q':
    d += [e[0]]
    c += [e[1]]
    e = input().split()
x = input().split()
s = 0
for i in range(len(x)):
    if x[i] in d:
        r = d.index(x[i])
        s += float(c[r])
print('total patmeny'+' '+str(s))
# 0081, 2022-02-24 08:17:00, PP (100%)

d = []
c = []
e = input().split()
while e[0] != 'q':
    d += [e[0]]
    c += [e[1]]
    e = input().split()
x = input().split()
s = 0
for i in range(len(x)):
    if x[i] in d:
        r = d.index(x[i])
        s += float(c[r])
print('total payment'+' '+str(s))

# 0082, 2022-02-24 08:12:08, compilation error (0%)

t = 0
a = []
while True:
    x = input()
    if x == 'q':
        break
    else:
        a.append(x.split())
b = [i for i in input().split()]
for i in b:
    for j in a:
        if i == j[0]:
            t += float(j[1])
print(f'total payment {t}')
# 0083, 2022-02-24 08:13:16, compilation error (0%)

t = 0
a = []
while True:
    x = input()
    if x == 'q':
        break
    else:
        a.append(x.split())
b = [i for i in input().split()]
for i in b:
    for j in a:
        if i == j[0]:
            t += float(j[1])
print(f'total payment {t}')
# 0084, 2022-02-24 08:14:04, xx (0%)

t = 0
a = []
while True:
    x = input()
    if x == 'q':
        break
    else:
        a.append(x.split())
b = [i for i in input().split()]
for i in b:
    for j in a:
        if i == j[0]:
            t += float(j[1])
print('total payment'+t)
# 0085, 2022-02-24 08:14:57, PP (100%)

t = 0
a = []
while True:
    x = input()
    if x == 'q':
        break
    else:
        a.append(x.split())
b = [i for i in input().split()]
for i in b:
    for j in a:
        if i == j[0]:
            t += float(j[1])
print('total payment' +" "+ str(t))

# 0086, 2022-02-24 08:08:56, xx (0%)

i = True
p = 0.0
set_e = []
while i == True:
  e = input()
  if e == 'p': break
  e = e.split()
  set_e.append(e)
k = input().split()
for t in range(len(k)):
  for a in range(len(set_e)):
    if set_e[a][0] == k[t]:
      p += float(set_e[a][1])
print('total payment '+str(p))

# 0087, 2022-02-24 08:09:27, xx (0%)

i = True
p = 0.0
set_e = []
while i == True:
  e = input()
  if e == 'p': i == False
  e = e.split()
  set_e.append(e)
k = input().split()
for t in range(len(k)):
  for a in range(len(set_e)):
    if set_e[a][0] == k[t]:
      p += float(set_e[a][1])
print('total payment '+str(p))
# 0088, 2022-02-24 08:11:52, xx (0%)

i = True
p = 0.0
set_e = []
while i == True:
  e = input()
  if e == 'q': i == False
  e = e.split()
  set_e.append(e)
k = input().split()
for t in range(len(k)):
  for a in range(len(set_e)):
    if set_e[a][0] == k[t]:
      p += float(set_e[a][1])
print('total payment '+str(p))
# 0089, 2022-02-24 08:14:33, PP (100%)

i = True
p = 0.0
set_e = []
while i == True:
  e = input()
  if e == 'q': i = False
  e = e.split()
  set_e.append(e)
k = input().split()
for t in range(len(k)):
  for a in range(len(set_e)):
    if set_e[a][0] == k[t]:
      p += float(set_e[a][1])
print('total payment '+str(p))

# 0090, 2022-02-24 08:05:59, compilation error (0%)

i = input().split()
name = []

while i != 'q':
    name.append([i[0],i[1]])
    i = input().split()
number = input().split()
money = 0
for i in range(len(nubmer)):
    for y in range(len(name))
        if nubmer[i] == name[y][0]:
            money = money+float(name[i][1])
            break
    


# 0091, 2022-02-24 08:06:09, xx (0%)

i = input().split()
name = []

while i != 'q':
    name.append([i[0],i[1]])
    i = input().split()
number = input().split()
money = 0
for i in range(len(nubmer)):
    for y in range(len(name)):
        if nubmer[i] == name[y][0]:
            money = money+float(name[i][1])
            break
    


# 0092, 2022-02-24 08:07:43, -x (0%)

i = input().split()
name = []

while i != ['q']:
    name.append([i[0],i[1]])
    i = input().split()
number = input().split()
money = 0
for i in range(len(number)):
    for y in range(len(name)):
        if number[i] == name[y][0]:
            money = money+float(name[i][1])
            break
    
# 0093, 2022-02-24 08:10:05, PP (100%)

i = input().split()
name = []

while i != ['q']:
    name.append([i[0],i[1]])
    i = input().split()
number = input().split()
money = 0
for i in range(len(number)):
    for y in range(len(name)):
        if number[i] == name[y][0]:
            money = money+float(name[y][1])
            break
print('total payment',money)
    



# 0094, 2022-02-24 08:14:10, xx (0%)

a=[]
i = 0
k = 0.0
while i != 'q':
    i = input()
    if i != 'q':
        i=i.split()
        a.append(i)
    else:
        pass
b = input().split()
print(a)
print(b)
for i in range(len(b)):
    for j in range(len(a)):
        if b[i] == a[j][0]:
            k+=float(a[j][1])
        else:
            pass
print('total payment ' + k)

        
    
    


# 0095, 2022-02-24 08:14:28, xx (0%)

a=[]
i = 0
k = 0.0
while i != 'q':
    i = input()
    if i != 'q':
        i=i.split()
        a.append(i)
    else:
        pass
b = input().split()
#print(a)
#print(b)
for i in range(len(b)):
    for j in range(len(a)):
        if b[i] == a[j][0]:
            k+=float(a[j][1])
        else:
            pass
print('total payment ' + k)
# 0096, 2022-02-24 08:15:09, PP (100%)

a=[]
i = 0
k = 0.0
while i != 'q':
    i = input()
    if i != 'q':
        i=i.split()
        a.append(i)
    else:
        pass
b = input().split()
#print(a)
#print(b)
for i in range(len(b)):
    for j in range(len(a)):
        if b[i] == a[j][0]:
            k+=float(a[j][1])
        else:
            pass
print('total payment ' + str(k))
# 0097, 2022-02-24 08:15:16, PP (100%)

a=[]
i = 0
k = 0.0
while i != 'q':
    i = input()
    if i != 'q':
        i=i.split()
        a.append(i)
    else:
        pass
b = input().split()
#print(a)
#print(b)
for i in range(len(b)):
    for j in range(len(a)):
        if b[i] == a[j][0]:
            k+=float(a[j][1])
        else:
            pass
print('total payment ' + str(k))

# 0098, 2022-02-24 08:09:44, xx (0%)

x = input().split()
a = []
name = []
price = []
allp = 0
while x != 'q':
    a.append([x])
    x = input().split()

y = input().split()

for i in range(len(a)):
    name.append(a[i][0])
    price.append(a[i][1])
    
for i in range(len(y)):
    if y[i] in name:
        p = name.index(y[i])
        allp += p
print('total payment',allp)
# 0099, 2022-02-24 08:12:01, -- (0%)

x = input().split()
a = []
name = []
price = []
allp = 0
while x != ['q']:
    a.append(x)
    x = input().split()

y = input().split()

for i in range(len(a)):
    name.append(a[i][0])
    price.append(a[i][1])
    
for i in range(len(y)):
    if y[i] in name:
        p = name.index(y[i])
        allp += p
print('total payment',allp)
# 0100, 2022-02-24 08:15:01, xx (0%)

x = input().split()
a = []
name = []
price = []
allp = 0
while x != ['q']:
    a.append(x)
    x = input().split()

y = input().split()

for i in range(len(a)):
    name.append(a[i][0])
    price.append(a[i][1])
    
for i in range(len(y)):
    if y[i] in name:
        p = name.index(y[i])
        allp += price[p]
print('total payment',allp)
# 0101, 2022-02-24 08:15:48, PP (100%)

x = input().split()
a = []
name = []
price = []
allp = 0
while x != ['q']:
    a.append(x)
    x = input().split()

y = input().split()

for i in range(len(a)):
    name.append(a[i][0])
    price.append(a[i][1])
    
for i in range(len(y)):
    if y[i] in name:
        p = name.index(y[i])
        allp += float(price[p])
print('total payment',allp)

# 0102, 2022-02-24 08:10:42, -- (0%)

x = input()
y = []
total = 0
while x != 'q':
    a,b = x.split()
    y.append([a,b])
    x = input()
    
offer = input()
for e in offer.split():
    for j in range(len(y)):
        if e == y[j][0]:
            total += float(y[j][1])
        
print(total)
        

# 0103, 2022-02-24 08:12:51, -- (0%)

x = input()
y = []
total = 0
while x != 'q':
    a,b = x.split()
    y.append([a,b])
    x = input()
    
offer = input()
for e in offer.split():
    for j in range(len(y)):
        if e == y[j][0]:
            total += float(y[j][1])
        
print('total payment' + str(total))
        

# 0104, 2022-02-24 08:14:11, -- (0%)

x = input()
y = []
total = 0
while x != 'q':
    a,b = x.split()
    y.append([a,b])
    x = input()
    
offer = input()
for e in offer.split():
    for j in range(len(y)):
        if e == y[j][0]:
            total += float(y[j][1])
        
print('total payment' + '' + str(total))
        

# 0105, 2022-02-24 08:14:23, PP (100%)

x = input()
y = []
total = 0
while x != 'q':
    a,b = x.split()
    y.append([a,b])
    x = input()
    
offer = input()
for e in offer.split():
    for j in range(len(y)):
        if e == y[j][0]:
            total += float(y[j][1])
        
print('total payment' + ' ' + str(total))

# 0106, 2022-02-24 08:06:55, compilation error (0%)

p=[]
price=[]
total = 0
a = input()
while a!= 'q':
    a = a.split()
    p.append(a[0])
    price.append(int(a[1])
    a = input()
b = input().split()
for i in b:
    total+= price[pp.index(i)]
print('total payment',total)

# 0107, 2022-02-24 08:07:59, xx (0%)

data1=[]
data2=[]
x=input()
a,b=x.split()
while x != q :
    data1.append(x)
    data2.append(y)
    x=input()
    a,b=x.split()
y=input().split()
sum=0
for i in y:
    for o in range (len(data1)):
      if i ==  data1[o]:
          sum+=data2[o]
print('total payment '+str(sum))
# 0108, 2022-02-24 08:10:34, xx (0%)

p=[]
price=[]
total = 0
a = input()
while a[0]!= 'q':
    p.append(a[0])
    price.append(int(a[1]))
    a = input().split()
b = input().split()
for i in b:
    total+= price[pp.index(i)]
print('total payment',total)


# 0109, 2022-02-24 08:13:08, PP (100%)

p=[]
price=[]
total = 0
a = input().split()
while a[0]!= 'q':
    p.append(a[0])
    price.append(float(a[1]))
    a = input().split()
b = input().split()
for i in b:
    total+= price[p.index(i)]
print('total payment',total)



# 0110, 2022-02-24 08:09:10, xx (0%)

a = input()
nlist = []
plist = []
all = []
while a != 'q':
    name,price = a.split()
    nlist.append(name)
    plist.append(price)
    a = input()
buy = input().split()
for e in buy:
    if e in nlist:
        all.append(plist.index(e))
total = sum(all)
print('total payment',total)
    


# 0111, 2022-02-24 08:11:48, xx (0%)

a = input()
nlist = []
plist = []
all = []
while a != 'q':
    name,price = a.split()
    nlist.append(name)
    plist.append(price)
    a = input()
buy = input().split()
for e in buy:
    if e in nlist:
        all.append(plist.index(e))
total = sum(all)
print('total payment',total)



# 0112, 2022-02-24 08:12:16, xx (0%)

a = input()
nlist = []
plist = []
all = []
while a != 'q':
    name,price = a.split()
    nlist.append(name)
    plist.append(float(price))
    a = input()
buy = input().split()
for e in buy:
    if e in nlist:
        all.append(plist.index(e))
total = sum(all)
print('total payment',total)



# 0113, 2022-02-24 08:14:24, PP (100%)

a = input()
nlist = []
plist = []
all = []
while a != 'q':
    name,price = a.split()
    nlist.append(name)
    plist.append(float(price))
    a = input()
buy = input().split()
for e in buy:
    if e in nlist:
        all.append(plist[nlist.index(e)])
total = sum(all)
print('total payment',total)




# 0114, 2022-02-24 08:13:40, xx (0%)

price = []
name = []
x = input()
while x != 'q':
    a,b = x.split()
    name += a
    price += b
    x = input()
want = input().split()
c = 0
for i in range(len(want)):
    for j in range(len(name)):
        if want[i] == name[j]:
            c += float(price[j])
print("total payment "+c)
# 0115, 2022-02-24 08:14:49, xx (0%)

price = []
name = []
x = input()
while x != 'q':
    a,b = x.split()
    name += [a]
    price += [b]
    x = input()
want = input().split()
c = 0
for i in range(len(want)):
    for j in range(len(name)):
        if want[i] == name[j]:
            c += float(price[j])
print("total payment "+c)
# 0116, 2022-02-24 08:15:54, PP (100%)

price = []
name = []
x = input()
while x != 'q':
    a,b = x.split()
    name += [a]
    price += [b]
    x = input()
want = input().split()
c = 0
for i in range(len(want)):
    for j in range(len(name)):
        if want[i] == name[j]:
            c += float(price[j])
print("total payment ",c)
# 0117, 2022-02-24 08:16:14, PP (100%)

price = []
name = []
x = input()
while x != 'q':
    a,b = x.split()
    name += [a]
    price += [b]
    x = input()
want = input().split()
c = 0
for i in range(len(want)):
    for j in range(len(name)):
        if want[i] == name[j]:
            c += float(price[j])
print("total payment",c)

# 0118, 2022-02-24 08:04:42, xx (0%)

x = ""
name = []
price = []

while x != "q":
    x = input().split()
    name.append(x[0])
    price.append(float(x[1]))

buy = input().split()

total = 0
for e in buy:
    if e in name:
        total += price[name.index(e)]


print("total payment", total)
# 0119, 2022-02-24 08:05:46, xx (0%)

name = []
price = []
x = input().split()

while x != "q":
    name.append(x[0])
    price.append(float(x[1]))
    x = input().split()

buy = input().split()

total = 0
for e in buy:
    if e in name:
        total += price[name.index(e)]


print("total payment", total)
# 0120, 2022-02-24 08:06:41, -- (0%)

name = []
price = []
x = input()

while x != "q":
    x.split()
    name.append(x[0])
    price.append(float(x[1]))
    x = input()

buy = input().split()

total = 0
for e in buy:
    if e in name:
        total += price[name.index(e)]


print("total payment", total)
# 0121, 2022-02-24 08:08:57, PP (100%)


name = []
price = []
x = input()

while x != "q":
    p = x.split()
    name.append(p[0])
    price.append(float(p[1]))
    x = input()

buy = input().split()

total = 0
for e in buy:
    if e in name:
        total += price[name.index(e)]


print("total payment", total)

# 0122, 2022-02-24 08:02:51, -- (0%)

total = 0
while True:
 goods = input().split()
 if 'q' in goods: break
 total += float(goods[1])
print(total)
# 0123, 2022-02-24 08:06:19, compilation error (0%)

total = 0
a = []
b = []
while True:
 goods = input().split()
 a.append(goods[0])
 b.append(goods[1])
 if 'q' in goods: break
som = input().split()
for i in range(len(a)):
  for e in som:
    if e == a[i]
    total += float(b[i])
print(total)
# 0124, 2022-02-24 08:07:18, xx (0%)

total = 0
a = []
b = []
while True:
 goods = input().split()
 a.append(goods[0])
 b.append(goods[1])
 if 'q' in goods: break
som = input().split()
for i in range(len(a)):
  for e in som:
    if e == a[i]:
      total += float(b[i])
print(total)
# 0125, 2022-02-24 08:10:01, PP (100%)

total = 0
a = []
b = []
while True:
 goods = input().split()
 if 'q' in goods: break
 else:
   a.append(goods[0])
   b.append(goods[1])
som = input().split()
for i in range(len(a)):
  for e in som:
    if e == a[i]:
      total += float(b[i])
print('total payment',total)

# 0126, 2022-02-24 08:11:45, compilation error (0%)

name=''
price={}
name=[e for e in input().split()]
while name[0]!="q":
  # print(name)
  price[name[0]]=float(name[1])
  name=[e for e in input().split()]
buy=input().split()
ans=0
for i in buy:
  ans+=price[i]
print(f'total payment {ans}')

# 0127, 2022-02-24 08:13:55, compilation error (0%)

name=''
price=[]
name=[e for e in input().split()]
while name[0]!="q":
  # print(name)
  price.append(name)
  name=[e for e in input().split()]
buy=input().split()
ans=0
for i in buy:
  for j in price:
    if(i == j[0]):
      ans += float(j[1])
print(f'total payment {ans}')
# 0128, 2022-02-24 08:14:58, compilation error (0%)

name=''
price=[]
name=[e for e in input().split()]
while name[0]!="q":
  # print(name)
  price.append(name)
  name=[e for e in input().split()]
buy=input().split()
ans=0
for i in buy:
  for j in price:
    if(i == j[0]):
      ans += float(j[1])
print(f'total payment {ans}')
# 0129, 2022-02-24 08:15:27, PP (100%)

name=''
price=[]
name=[e for e in input().split()]
while name[0]!="q":
  # print(name)
  price.append(name)
  name=[e for e in input().split()]
buy=input().split()
ans=0
for i in buy:
  for j in price:
    if(i == j[0]):
      ans += float(j[1])
print('total payment '+str(ans))

# 0130, 2022-02-24 08:11:30, -- (0%)

y=[]
k='a'
while(k!='q') :
    k=input()
    if(k=='q') :
        break
    x=k.split()
    y.append(x)
#print(y)
    
#y is list of goods and price
    
buynonuse=input()
buy=buynonuse.split()
print(buy)
totalpay=0
for i in range(len(buy)) : #ของที่ซื้อ
    for j in range(len(y)) :# รายการสินค้า
        if(buy[i]==y[j][0]) :
            totalpay+=float(y[j][1])
print("total payment ",end="")
print(totalpay)
    

# 0131, 2022-02-24 08:12:11, -- (0%)

y=[]
k='a'
while(k!='q') :
    k=input()
    if(k=='q') :
        break
    x=k.split()
    y.append(x)
#print(y)
    
#y is list of goods and price
    
buynonuse=input()
buy=buynonuse.split()
print(buy)
totalpay=0
for i in range(len(buy)) : #ของที่ซื้อ
    for j in range(len(y)) :# รายการสินค้า
        if(buy[i]==y[j][0]) :
            totalpay+=float(y[j][1])
#print("total payment ",end="")
print(totalpay)
    

# 0132, 2022-02-24 08:12:19, -- (0%)

y=[]
k='a'
while(k!='q') :
    k=input()
    if(k=='q') :
        break
    x=k.split()
    y.append(x)
#print(y)
    
#y is list of goods and price
    
buynonuse=input()
buy=buynonuse.split()
#print(buy)
totalpay=0
for i in range(len(buy)) : #ของที่ซื้อ
    for j in range(len(y)) :# รายการสินค้า
        if(buy[i]==y[j][0]) :
            totalpay+=float(y[j][1])
#print("total payment ",end="")
print(totalpay)
# 0133, 2022-02-24 08:13:09, PP (100%)

y=[]
k='a'
while(k!='q') :
    k=input()
    if(k=='q') :
        break
    x=k.split()
    y.append(x)
#print(y)
    
#y is list of goods and price
    
buynonuse=input()
buy=buynonuse.split()
#print(buy)
totalpay=0
for i in range(len(buy)) : #ของที่ซื้อ
    for j in range(len(y)) :# รายการสินค้า
        if(buy[i]==y[j][0]) :
            totalpay+=float(y[j][1])
print("total payment ",end="")
print(totalpay)
    


# 0134, 2022-02-24 08:15:44, PP (100%)

m = input()
price = []
while m != 'q' :
    price.append(m.split())
    m = input()
want = input().split()
total_price = 0
for e in want :
    for i in price :
        if e == i[0] :
            total_price += float(i[1])
print('total payment',total_price)

# 0135, 2022-02-24 08:15:52, PP (100%)

m = input()
price = []
while m != 'q' :
    price.append(m.split())
    m = input()
want = input().split()
total_price = 0
for e in want :
    for i in price :
        if e == i[0] :
            total_price += float(i[1])
print('total payment',total_price)
# 0136, 2022-02-24 08:16:00, PP (100%)

m = input()
price = []
while m != 'q' :
    price.append(m.split())
    m = input()
want = input().split()
total_price = 0
for e in want :
    for i in price :
        if e == i[0] :
            total_price += float(i[1])
print('total payment',total_price)
# 0137, 2022-02-24 08:16:06, PP (100%)

m = input()
price = []
while m != 'q' :
    price.append(m.split())
    m = input()
want = input().split()
total_price = 0
for e in want :
    for i in price :
        if e == i[0] :
            total_price += float(i[1])
print('total payment',total_price)


# 0138, 2022-02-24 08:10:17, -- (0%)

x = input()
price = []
product = []

while x != "q" :
    pro, pri = x.split()
    product.append(pro)
    price.append(pri)
    x = input()
    
total = []    
for i in range(len(price)):
    total.append(float(price[i]))
a = sum(total)
print(a)
print('total payment',a)
# 0139, 2022-02-24 08:10:31, -- (0%)

x = input()
price = []
product = []

while x != "q" :
    pro, pri = x.split()
    product.append(pro)
    price.append(pri)
    x = input()
    
total = []    
for i in range(len(price)):
    total.append(float(price[i]))
a = sum(total)
print('total payment',a)
# 0140, 2022-02-24 08:13:09, -- (0%)

x = input()
price = []
product = []

while x != "q" :
    pro, pri = x.split()
    product.append(pro)
    price.append(pri)
    x = input()
    
total = []    
for i in range(len(price)):
    total.append(float(price[i]))
a = sum(total)
print('total payment ',a)
# 0141, 2022-02-24 08:15:42, PP (100%)

x = input().split()
product = []
price = []
a = 0
while x[0] != "q":
    product.append(x[0])
    price.append(float(x[1]))
    x = input().split()
y = input().split()
for i in range(len(y)):
    if y[i] in product:
        b = product.index(y[i])
        a += price[b]
print("total payment ", a)

# 0142, 2022-02-24 08:10:56, -- (0%)

d = []
g = []
y = []
c = 0.0
while True:
    x = input()
    if x == "q":
        break
    else:
        i,j = x.split()
        g.append(i)
        y.append(j)
        
thing = input().split()
for i in thing:
    if i in g:
        j = g.index(i)
        c += float(y[j])
        
print('totol payment',c)
        

        

# 0143, 2022-02-24 08:11:16, -- (0%)

d = []
g = []
y = []
c = 0.0
while True:
    x = input()
    if x == "q":
        break
    else:
        i,j = x.split()
        g.append(i)
        y.append(j)
        
thing = input().split()
for i in thing:
    if i in g:
        j = g.index(i)
        c += float(y[j])
        
print('totol payment',c)
# 0144, 2022-02-24 08:11:59, PP (100%)

d = []
g = []
y = []
c = 0.0
while True:
    x = input()
    if x == "q":
        break
    else:
        i,j = x.split()
        g.append(i)
        y.append(j)
        
thing = input().split()
for i in thing:
    if i in g:
        j = g.index(i)
        c += float(y[j])
        
print('total payment',c)

# 0145, 2022-02-24 08:14:22, -- (0%)

a=input()
b=[]
k=0
while a!='q':
    a=a.split()
    b.append(a)
    a=input()
c=input().split()
print(c)
for i in range(len(c)):
    for j in b:
        if c[i] in j:
            k+=float(j[1])
print('total payment',k)
# 0146, 2022-02-24 08:14:56, -- (0%)

a=input()
b=[]
k=0
while a!='q':
    a=a.split()
    b.append(a)
    a=input()
c=input().split()
print(c)
for i in range(len(c)):
    for j in b:
        if c[i] in j:
            k+=float(j[1])
print('total payment'+str(k))
# 0147, 2022-02-24 08:16:18, PP (100%)

a=input()
b=[]
k=0
while a!='q':
    a=a.split()
    b.append(a)
    a=input()
c=input().split()
for i in range(len(c)):
    for j in b:
        if c[i] in j:
            k+=float(j[1])
print('total payment',k)

# 0148, 2022-02-24 08:04:23, xx (0%)

s = input()
d = list()
while s != q:
  d.append(s.split())
  s = input()
b = input.split()
p = 0
for e in b:
  for i in range(len(d)):
    if d[i][0] == e:p += float(d[i][1])
print("total payment",p)
# 0149, 2022-02-24 08:04:52, xx (0%)

s = input()
d = list()
while s != 'q':
  d.append(s.split())
  s = input()
b = input.split()
p = 0
for e in b:
  for i in range(len(d)):
    if d[i][0] == e:p += float(d[i][1])
print("total payment",p)
# 0150, 2022-02-24 08:06:06, PP (100%)

s = input()
d = list()
while s != 'q':
  d.append(s.split())
  s = input()
b = input().split()
p = 0
for e in b:
  for i in range(len(d)):
    if d[i][0] == e:p += float(d[i][1])
print("total payment",p)

# 0151, 2022-02-24 08:07:03, -- (0%)

x = input(); name = []; price = []; sum = 0
while x != 'q' :
    a,b = x.split()
    name.append(a)
    price.append(float(b))
    x = input()
buy = input().split()
for e in buy :
    ind = name.index(e)
    sum += price[ind]
print ('Total Payment', sum)
# 0152, 2022-02-24 08:07:26, -- (0%)

x = input(); name = []; price = []; sum = 0
while x != 'q' :
    a,b = x.split()
    name.append(a)
    price.append(float(b))
    x = input()
buy = input().split()
for e in buy :
    ind = name.index(e)
    sum += price[ind]
print ('total Payment', sum)
# 0153, 2022-02-24 08:07:44, PP (100%)

x = input(); name = []; price = []; sum = 0
while x != 'q' :
    a,b = x.split()
    name.append(a)
    price.append(float(b))
    x = input()
buy = input().split()
for e in buy :
    ind = name.index(e)
    sum += price[ind]
print ('total payment', sum)

# 0154, 2022-02-24 08:06:23, xx (0%)

a=input()
s=[]
total=0
while a!= "q":
  s+=a.split()
  a=input()
b=input().split()
name=s[::2]
price=s[1::2]
b=input().split()
for i in range (len(b)):
    for j in range (len(name)):
      if b[i]==name[j]:
        total+= float(print[j])
print("total payment "+str())
# 0155, 2022-02-24 08:07:06, xx (0%)

a=input()
s=[]
total=0
while a!= "q":
  s+=a.split()
  a=input()
b=input().split()
name=s[::2]
price=s[1::2]
b=input().split()
for i in range (len(b)):
    for j in range (len(name)):
      if b[i]==name[j]:
        total+= float(print[j])
print("total payment "+str(total))
# 0156, 2022-02-24 08:09:35, PP (100%)

a=input()
s=[]
total=0
while a!= "q":
  s+=a.split()
  a=input()
b=input().split()
name=s[::2]
price=s[1::2]
for i in range (len(b)):
    for j in range (len(name)):
      if b[i]==name[j]:
        total+= float(price[j])
print("total payment "+str(total))

# 0157, 2022-02-24 08:04:39, -- (0%)

x = input()
a = []
b = []
while x != 'q':
    y = x.split()
    a.append(y[0])
    b.append(y[1])
    x = input()
x = input().split()
total = []
for i in x:
    total.append(b[a.index(i)])
print('total payment', total)
# 0158, 2022-02-24 08:05:12, xx (0%)

x = input()
a = []
b = []
while x != 'q':
    y = x.split()
    a.append(y[0])
    b.append(y[1])
    x = input()
x = input().split()
total = []
for i in x:
    total.append(b[a.index(i)])
print('total payment', sum(total))
# 0159, 2022-02-24 08:06:00, PP (100%)

x = input()
a = []
b = []
while x != 'q':
    y = x.split()
    a.append(y[0])
    b.append(y[1])
    x = input()
x = input().split()
total = []
for i in x:
    total.append(float(b[a.index(i)]))
print('total payment', sum(total))

# 0160, 2022-02-24 08:07:09, xx (0%)

inp = input().split()
data = []
while cin != ["q"]:
    data.append(inp)
buy = input().split()
price = 0
for e in buy:
    for d in data:
        if e == d[0]:
            price += d[1]

print("total payment", price)

# 0161, 2022-02-24 08:07:35, TT (0%)

inp = input().split()
data = []
while inp != ["q"]:
    data.append(inp)
buy = input().split()
price = 0
for e in buy:
    for d in data:
        if e == d[0]:
            price += d[1]

print("total payment", price)
# 0162, 2022-02-24 08:12:25, PP (100%)

inp = input().split()
data = []
while inp != ["q"]:
    data.append(inp)
    inp = input().split()
buy = input().split()
price = 0
for e in buy:
    for d in data:
        if e == d[0]:
            price += float(d[1])
print("total payment", price)

# 0163, 2022-02-24 08:10:49, xx (0%)

list_1 = input()
x = []
total = 0

while list_1 != "q":
    X.append(ABC.split())
    list_1 = input()
for i in input().split():
    for e in X:
        if i == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0164, 2022-02-24 08:12:27, PP (100%)

list_1 = input()
x = []
total = 0

while list_1 != "q":
    x.append(list_1.split())
    list_1 = input()
for i in input().split():
    for e in x:
        if i == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0165, 2022-02-24 08:15:50, PP (100%)

list_1 = input()
x = []
total = 0
while list_1 != "q":
    x.append(list_1.split())
    list_1 = input()
for i in input().split():
    for e in x:
        if i == e[0]:
            total += float(e[1])
            break
print("total payment", total)

# 0166, 2022-02-24 08:11:15, -x (0%)

price = []
a = input()
while a != "q":
    b = a.split()
    price.append(b)
    a = input()
b = a.split()
price.append(b)
prod = input().split()
total = 0
for i in range(len(prod)):
    if price[i][0] in prod:
        total += float(price[i][1])
print("total payment",total)
# 0167, 2022-02-24 08:12:05, P- (50%)

price = []
a = input()
while a != "q":
    b = a.split()
    price.append(b)
    a = input()
b = a.split()
price.append(b)
prod = input().split()
total = 0
for i in range(len(price)):
    if price[i][0] in prod:
        total += float(price[i][1])
print("total payment",total)
# 0168, 2022-02-24 08:15:31, PP (100%)

price = []
a = input()
while a != "q":
    b = a.split()
    price.append(b)
    a = input()
b = a.split()
price.append(b)
prod = input().split()
p = []
for t in range(len(price)):
    p.append(price[t][0])
total = 0
for i in range(len(prod)):
    total += float(price[p.index(prod[i])][1])
print("total payment",total)

# 0169, 2022-02-24 08:14:08, PP (100%)


y = input().split()
d =[]

while y != ['q']:
    d.append(y)
    y = input().split()
    
list_ = input().split()

tc = 0
for i in list_:
    for ii in range(len(d)):
        if i == d[ii][0]:
            tc += float(d[ii][1])
    

print('total payment',tc)
    



# 0170, 2022-02-24 08:14:13, PP (100%)

y = input().split()
d =[]

while y != ['q']:
    d.append(y)
    y = input().split()
    
list_ = input().split()

tc = 0
for i in list_:
    for ii in range(len(d)):
        if i == d[ii][0]:
            tc += float(d[ii][1])
    

print('total payment',tc)
# 0171, 2022-02-24 08:14:33, PP (100%)

y = input().split()
d =[]

while y != ['q']:
    d.append(y)
    y = input().split()
    
list_ = input().split()

tc = 0
for i in list_:
    for ii in range(len(d)):
        if i == d[ii][0]:
            tc += float(d[ii][1])
    

print('total payment',tc)

# 0172, 2022-02-24 08:13:38, xx (0%)

goods = []
price = []
x = ''
s=0

while x != 'q' :
  x = input().split()
  goods.append(x[0])
  price.append(x[1])


n = input().split()
for e in n:
  s = s + float(price[goods(e)])

print('total payment',s)

# 0173, 2022-02-24 08:15:36, PP (100%)

p = input().split()

name = []

while p != ['q']:
    name.append(p)
    p = input().split()
    
buy_list = input().split()

cost = 0
for e in range(len(buy_list)):
    for i in range(len(name)):        
        if buy_list[e] == name[i][0]:
            cost += float(name[i][1])
            
print('total payment',cost)
# 0174, 2022-02-24 08:15:55, PP (100%)

p = input().split()

name = []

while p != ['q']:
    name.append(p)
    p = input().split()
    
buy_list = input().split()

cost = 0
for e in range(len(buy_list)):
    for i in range(len(name)):        
        if buy_list[e] == name[i][0]:
            cost += float(name[i][1])
            
print('total payment',cost)

# 0175, 2022-02-24 08:06:25, -- (0%)

s2 = []
s3 = []
sm = 0
while 1:
	s = input().split()
	if len(s)==1:
		break;
	s[1] = float(s[1])
	s2.append(s[0])
	s3.append(s[1])
print(len(s3))
s4 = input().split()
for i in s4:
	pos = s2.index(i)
	print(pos)
	sm+=s3[pos]
print("total payment",sm)

# 0176, 2022-02-24 08:08:41, -- (0%)

s2 = []
s3 = []
sm = 0
while 1:
	s = input().split()
	if len(s)==1:
		break;
	s[1] = float(s[1])
	s2.append(s[0])
	s3.append(s[1])
print(len(s3))
s4 = input().split()
for i in s4:
	for j in range(len(s2)):
		if s2[j]==i:
			sm+=s3[j]
print("total payment",sm)

# 0177, 2022-02-24 08:09:22, PP (100%)

s2 = []
s3 = []
sm = 0
while 1:
	s = input().split()
	if len(s)==1:
		break;
	s[1] = float(s[1])
	s2.append(s[0])
	s3.append(s[1])
s4 = input().split()
for i in s4:
	for j in range(len(s2)):
		if s2[j]==i:
			sm+=s3[j]
print("total payment",sm)


# 0178, 2022-02-24 08:05:10, xx (0%)

a=input()
b=[]
while a!= 'q':
    b.append(a.split())
    a=input()
if a=='q':
    c=input.split()
t=0.0
for i in c:
    t+=int(b[b.index(i)+1])
print('total payment',c)

# 0179, 2022-02-24 08:09:34, -- (0%)

a=input()
b=[]
while a!= 'q':
    x,y=a.split()
    b.append(x)
    b.append(y)
    a=input()
if a=='q':
    c=input().split()
t=0.0
for i in c:
    t+=float(b[b.index(i)+1])
print('total payment',c)


# 0180, 2022-02-24 08:10:40, PP (100%)

a=input()
b=[]
while a!= 'q':
    x,y=a.split()
    b.append(x)
    b.append(y)
    a=input()
if a=='q':
    c=input().split()
t=0.0
for i in c:
    t+=float(b[b.index(i)+1])
print('total payment',t)



# 0181, 2022-02-24 08:09:02, xx (0%)

a,b  = [], []
while True :
    n = input().split()
    if n[0] == 'q' : break
    a.append(n[0])
    b += float(n[1])
m = input().split()
c = 0
for i in range(len(m)):
    k = b.index(m[i])
    c += b[k]
print('total payment ',)


# 0182, 2022-02-24 08:09:11, xx (0%)

a,b  = [], []
while True :
    n = input().split()
    if n[0] == 'q' : break
    a.append(n[0])
    b += float(n[1])
m = input().split()
c = 0
for i in range(len(m)):
    k = b.index(m[i])
    c += b[k]
print('total payment ',c)
# 0183, 2022-02-24 08:12:37, PP (100%)

a,b  = [], []
while True :
    n = input().split()
    if n[0] == 'q' : break
    a.append(n[0])
    b.append(n[1])
m = input().split()
c = 0
for i in range(len(m)):
    k = a.index(m[i])
    c += float(b[k])
print('total payment ',c)



# 0184, 2022-02-24 08:10:25, xx (0%)

c = list()

x = input()
while(x != "q"):
    name,price = x.split()
    c.append([name,float(price)])
    x = input()
total = 0
buy = input().split()
for x in buy:
    for i in range(len(c)):
        if(c[i][0] == x):
            c = c + data[i][1]
            break
print("total payment %f" %c)
# 0185, 2022-02-24 08:13:07, PP (100%)

c = list()
temp = input()
while(temp != "q"):
    name,price = temp.split()
    c.append([name,float(price)])
    temp = input()
    
total = 0
by = input().split()
for m in by:
    for i in range(len(c)):
        if(c[i][0] == m):
            total = total + c[i][1]
            break
print(  "total payment ",end=''  )
print(  total  )
# 0186, 2022-02-24 08:15:05, PP (100%)

c  =  list()
temp  =  input()
while(temp  !=  "q"):
    name,price  =  temp.split()
    c.append( [ name,float(price) ] )
    temp  =  input()
    
total  =  0
b  =  input().split()
for m in b :
    for i in range(len(c)):
        if(c[i][0]  ==  m):
            total  =  total + c[i][1]
            break
print(  "total payment ",end=''  )
print(  total  )

# 0187, 2022-02-24 08:09:37, xx (0%)

y = input()
s = []
while y != "q":
    y.split()
    y[1] = float(y[1])
    s.append([y])
    y = input()
gg = input().split()
r = []
for name,price in s:
    for q in gg:
        if q == name:
            r += price
print("total payment"+str(r))
# 0188, 2022-02-24 08:11:11, xx (0%)

y = input()
s = []
while y != "q":
    t = y.split()
    t[1] = float(t[1])
    s.append([t])
    y = input()
gg = input().split()
r = []
for name,price in s:
    for q in gg:
        if q == name:
            r += price
print("total payment"+str(r))
# 0189, 2022-02-24 08:13:50, PP (100%)

y = input()
s = []
while y != "q":
    t = y.split()
    t[1] = float(t[1])
    s.append(t)
    y = input()
gg = input().split()
r = 0
for name,price in s:
    for q in gg:
        if q == name:
            r += price
print("total payment "+str(r))

# 0190, 2022-02-24 08:12:55, xx (0%)

products = []

while True:
    inp = input().split()
    if len(inp) == 2:
        prod, price = inp
        prods.append((prod, float(price)))
    elif len(inp) == 1 and inp[0] == 'q':
        break
buys = input().split()
total = 0
for prod in buys:
    for p in prods:
        if prod.lower() == p[0].lower():
            total += p[1]
            break
print("total payment", total)

# 0191, 2022-02-24 08:14:33, xx (0%)

products = []

while True:
    inp = input().split()
    if len(inp) == 2:
        prod, price = inp
        prods.append((prod, float(price)))
    elif len(inp) == 1 and inp[0] == 'q':
        break
buys = input().split()
total = 0
for prod in buys:
    for p in prods:
        if prod.lower() == p[0].lower():
            total += p[1]
            break
print("total payment", total)
# 0192, 2022-02-24 08:15:13, PP (100%)

prods = []

while True:
    inp = input().split()
    if len(inp) == 2:
        prod, price = inp
        prods.append((prod, float(price)))
    elif len(inp) == 1 and inp[0] == 'q':
        break
buys = input().split()
total = 0
for prod in buys:
    for p in prods:
        if prod.lower() == p[0].lower():
            total += p[1]
            break
print("total payment", total)

# 0193, 2022-02-24 08:12:42, -- (0%)

pro=[]
a=input().split()
while a[0]!='q':
    pro.append(a[0])
    pro.append(a[1])
    a=input().split()
b=input().split()
p=0.0
for e in b:
    if e in pro:
        i=pro.index(e)
        p+=float(pro[i+1])
print("Total payment,p")
# 0194, 2022-02-24 08:13:25, -- (0%)

pro=[]
a=input().split()
while a[0]!='q':
    pro.append(a[0])
    pro.append(a[1])
    a=input().split()
b=input().split()
p=0.0
for e in b:
    if e in pro:
        i=pro.index(e)
        p+=float(pro[i+1])
print("Total payment",p)
# 0195, 2022-02-24 08:14:05, PP (100%)

pro=[]
a=input().split()
while a[0]!='q':
    pro.append(a[0])
    pro.append(a[1])
    a=input().split()
b=input().split()
p=0.0
for e in b:
    if e in pro:
        i=pro.index(e)
        p+=float(pro[i+1])
print("total payment",p)

# 0196, 2022-02-24 08:04:27, xx (0%)

name = []
prize = []
total = 0

while n != 'q' :
    code = input().split()
    name.append(code[0])
    prize.append(float(code[1]))
    
buy = input().split()

for e in buy:
    if e in name:
        i = name.index(e)
        tatal += prize[i]
print ('total payment',total)
# 0197, 2022-02-24 08:05:44, xx (0%)

code = input().split()

name = []
prize = []
total = 0

while code != 'q' :
    name.append(code[0])
    prize.append(float(code[1]))
    code = input().split()
    
buy = input().split()

for e in buy:
    if e in name:
        i = name.index(e)
        tatal += prize[i]
print ('total payment',total)
# 0198, 2022-02-24 08:10:04, PP (100%)

code = input().split()
name = []
prize = []
total = 0

while code[0] != 'q' :
    name.append(code[0])
    prize.append(float(code[1]))
    code = input().split()
    
buy = input().split()

for e in buy:
    if e in name:
        i = name.index(e)
        total += prize[i]
print ('total payment',total)

# 0199, 2022-02-24 08:08:35, PP (100%)

inp = input()

all_prods = []
while inp != 'q' :
    prod = inp.split()
    all_prods.append(prod)
    inp = input()
buying = input().split()

name = []
for e in all_prods :
    name.append(e[0])

total = 0
for e in buying :
    a = name.index(e)
    total += float(all_prods[a][1])
print('total payment', total)

# 0200, 2022-02-24 08:08:58, PP (100%)

inp = input()

all_prods = []
while inp != 'q' :
    prod = inp.split()
    all_prods.append(prod)
    inp = input()
buying = input().split()

name = []
for e in all_prods :
    name.append(e[0])

total = 0
for e in buying :
    a = name.index(e)
    total += float(all_prods[a][1])

print('total payment', total)

# 0201, 2022-02-24 08:04:07, xx (0%)

x = input().split()
id_goods = []
price = []
while x[0] != 'q':
    id_goods.append(float(x[0]))
    price.append(float(x[1]))
    x = input().split()
want = input().split()
total = 0
for e in want:
    if e in id_goods:
        a = id_goods.index(e)
        total += price[a]
print('total payment {}'.format(total))
# 0202, 2022-02-24 08:04:53, PP (100%)

x = input().split()
id_goods = []
price = []
while x[0] != 'q':
    id_goods.append(x[0])
    price.append(float(x[1]))
    x = input().split()
want = input().split()
total = 0
for e in want:
    if e in id_goods:
        a = id_goods.index(e)
        total += price[a]
print('total payment {}'.format(total))

# 0203, 2022-02-24 08:12:55, -- (0%)

n = ' '
name = []
price = []
total = 0.0
while True:
    n = input().split()
    if n[0] == 'q':
        break
    name.append(n[0])
    price.append(n[1])

name_list = input().split()
print(name,price,name_list)

for i in range(len(name_list)):
    total = total + float(price[name.index(name_list[i])])

print('total payment '+str(total))


# 0204, 2022-02-24 08:13:51, PP (100%)

n = ' '
name = []
price = []
total = 0.0
while True:
    n = input().split()
    if n[0] == 'q':
        break
    name.append(n[0])
    price.append(n[1])

name_list = input().split()

for i in range(len(name_list)):
    total = total + float(price[name.index(name_list[i])])

print('total payment '+str(total))

# 0205, 2022-02-24 08:05:48, xx (0%)

n = input()
buy = []
while n != 'q':
    name,price = n.split()
    buy.append([name,int(price)])
    n = input()
a = input().split()
price = 0
for i in a:
    for x,y in buy:
        if i == x :
            price += y
print("total payment",price)
# 0206, 2022-02-24 08:06:45, PP (100%)

n = input()
buy = []
while n != 'q':
    name,price = n.split()
    buy.append([name,float(price)])
    n = input()
a = input().split()
price = 0
for i in a:
    for x,y in buy:
        if i == x :
            price += y
print("total payment",price)

# 0207, 2022-02-24 08:07:04, xx (0%)

l = 'fg'
h = []
while l != 'q' :
  l = input()
  h.append([i for i in l.split()])
a = [i for i in input().split()]
k = 0
for i in range(len(a)):
  for j in h :
    if a[i]==j[0] :
      k+= j[1]
      
print('total payment '+str(k))
  
# 0208, 2022-02-24 08:08:15, PP (100%)

l = 'fg'
h = []
while l != 'q' :
  l = input()
  h.append([i for i in l.split()])
a = [i for i in input().split()]
k = 0
for i in range(len(a)):
  for j in h :
    if a[i]==j[0] :
      k+= float(j[1])
      
print('total payment '+str(k))

# 0209, 2022-02-24 08:05:52, xx (0%)

x = input()
goods = {}
while x != 'q':
    name,price = x.split()
    goods[name] = float(price)
    x = input()

buy = input()
All_Buy = input().split()
total = 0
for e in All_Buy:
    total += goods[e]

print('total payment '+str(total))
# 0210, 2022-02-24 08:06:35, PP (100%)

x = input()
goods = {}
while x != 'q':
    name,price = x.split()
    goods[name] = float(price)
    x = input()

All_Buy = input().split()
total = 0
for e in All_Buy:
    total += goods[e]

print('total payment '+str(total))

# 0211, 2022-02-24 08:08:25, xx (0%)

listproduct=[]
listprice=[]
while True:
    product_price=input().split()
    if product_price=='q':
        break
    else:
        product,price=product_price.split()
        listproduct.append(product)
        listprice.append(int(price))
order=input().split()
totalpayment=0
for i in order:
    if i in listproduct:
        position=listproduct.index(i)
        totalpayment+=listprice[position]
print('total payment '+totalpayment)





# 0212, 2022-02-24 08:11:21, PP (100%)

listproduct=[]
listprice=[]
while True:
    product_price=input()
    if product_price=='q':
        break
    else:
        product,price=product_price.split()
        listproduct.append(product)
        listprice.append(float(price))
order=input().split()
totalpayment=0
for i in order:
    if i in listproduct:
        position=listproduct.index(i)
        totalpayment+=listprice[position]
print('total payment '+str(totalpayment))






# 0213, 2022-02-24 08:06:37, -- (0%)

e= input()
c=0
l1=[]
l2=[]
while e != "q":
    e = e.split()
    l1.append(e[0])
    l2.append(float(e[1]))
    e= input()
buy=input().split()
for i in range(len(buy)):
    c+=l2[l1.index(buy[i])]
print(c)
# 0214, 2022-02-24 08:07:18, PP (100%)

e= input()
c=0
l1=[]
l2=[]
while e != "q":
    e = e.split()
    l1.append(e[0])
    l2.append(float(e[1]))
    e= input()
buy=input().split()
for i in range(len(buy)):
    c+=l2[l1.index(buy[i])]
print("total payment {}".format(c))

# 0215, 2022-02-24 08:09:41, -- (0%)

check = True
name = []
price = []
total = 0
while check == True :
    x = input().split()
    if x[0] == 'q':
        check = False
    else :
        name.append(x[0])
        price.append(x[1])

my_list = input().split()
print(my_list)
for i in my_list :
    inx = name.index(i)
    total += float(price[inx])

print('total payment ' + str(total))

# 0216, 2022-02-24 08:11:23, PP (100%)

check = True
name = []
price = []
total = 0
while check == True :
    x = input().split()
    if x[0] == 'q':
        check = False
    else :
        name.append(x[0])
        price.append(x[1])

my_list = input().split()

for i in my_list :
    inx = name.index(i)
    total += float(price[inx])

print('total payment ' + str(total))

# 0217, 2022-02-24 08:10:16, -- (0%)

shop = [input()]
shopping_list = []
price = []
t_price = 0
while shop[-1]!= 'q':
    shop.append(input())
for i in range (len(shop) - 1):
    shop[i] = shop[i].split()
    shopping_list.append(shop[i][0])
    price.append(float(shop[i][1]))
buy = input().split()
for i in range (len(buy)):
    x = shopping_list.index(buy[i])
    t_price += price[x]
print(t_price)
# 0218, 2022-02-24 08:10:53, PP (100%)

shop = [input()]
shopping_list = []
price = []
t_price = 0
while shop[-1]!= 'q':
    shop.append(input())
for i in range (len(shop) - 1):
    shop[i] = shop[i].split()
    shopping_list.append(shop[i][0])
    price.append(float(shop[i][1]))
buy = input().split()
for i in range (len(buy)):
    x = shopping_list.index(buy[i])
    t_price += price[x]
print('total payment', t_price)

# 0219, 2022-02-24 08:11:45, PP (100%)

ABC = input()
XYZ = []
total = 0

while ABC != "q":
    XYZ.append(ABC.split())
    ABC = input()
for want in input().split():
    for e in XYZ:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)
# 0220, 2022-02-24 08:14:50, PP (100%)

f1 = input()
f2 = []
total = 0

while f1 != "q":
    f2.append(f1.split())
    f1 = input()
for want in input().split():
    for e in f2:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)

# 0221, 2022-02-24 08:06:28, TT (0%)

x=input().split()
a=[]
b=[]
while x!=['q']:
    a.append(x[0])
    b.append(float(x[1]))
y=input().split()
s=0
for i in y:
    if i in a:
        s+=b[a.index(i)]
print('total payment',s)   
    

# 0222, 2022-02-24 08:08:09, PP (100%)

x=input()
a=[]
b=[]
while x!='q':
    r=x.split()
    a.append(r[0])
    b.append(float(r[1]))
    x=input()
y=input().split()
s=0
for i in y:
    if i in a:
        s+=b[a.index(i)]
print('total payment',s)   
    


# 0223, 2022-02-24 08:12:23, xx (0%)

v = []
while True:
  a = input()
  if a == 'q':
    break
  a = a.split()
  x = a[0::2]
  y = a[1::2]
  y = float(y)
  v.append([x, y])
x = input().split()
sum = 0.0
for z in x:
  for i in v:
    if i[0] == z:
      sum += i[1]
print("total payment", sum)
# 0224, 2022-02-24 08:13:15, PP (100%)

v = []
while True:
  a = input()
  if a == 'q':
    break
  x, y = a.split()
  y = float(y)
  v.append([x, y])
x = input().split()
sum = 0.0
for z in x:
  for i in v:
    if i[0] == z:
      sum += i[1]
print("total payment", sum)

# 0225, 2022-02-24 08:14:14, PP (100%)

price = []
summ = []
while True:
    data = input().split()
    if data[0] == 'q':
        break
    price.append(data[0])
    price.append(data[1])
for i in range(len(price)):
    try:
        price[i] = float(price[i])
    except:
        pass
wanted = input().split()
for i in range(len(wanted)):
    pos = price.index(wanted[i])
    summ.append(price[pos+1])
summary = sum(summ)
print('total payment'+' '+str(summary))
# 0226, 2022-02-24 08:15:08, PP (100%)

price = []
summ = []
while True:
    data = input().split()
    if data[0] == 'q':
        break
    price.append(data[0])
    price.append(data[1])
for i in range(len(price)):
    try:
        price[i] = float(price[i])
    except:
        pass
wanted = input().split()
for i in range(len(wanted)):
    pos = price.index(wanted[i])
    summ.append(price[pos+1])
summary = sum(summ)
print('total payment'+' '+str(summary))

# 0227, 2022-02-24 08:08:02, -x (0%)

list1 = []
list2 = []
a = ''
while a != 'q':
    a = input()
    if len(a.split()) > 1:
        a = a.split()
        list1.append(a[0])
        list2.append(a[1])
b = input().split()
sumx = 0
for i in range(len(b)):
    for j in range(len(list1)):
        if b[i] == list1[j]:
            sumx = sumx + float(list2[i])
print('total payment',sumx)
# 0228, 2022-02-24 08:09:36, PP (100%)

list1 = []
list2 = []
a = ''
while a != 'q':
    a = input()
    if len(a.split()) > 1:
        a = a.split()
        list1.append(a[0])
        list2.append(a[1])
b = input().split()
sumx = 0
for i in range(len(b)):
    for j in range(len(list1)):
        if b[i] == list1[j]:
            sumx = sumx + float(list2[j])
print('total payment',sumx)

# 0229, 2022-02-24 08:11:44, xx (0%)

a=input().strip()
data=[] ; tt=0 ;n=[]
while a!='q':
    name,p=a.split()
    data.append([name,p])
    n.append(name)
    a=input().strip()
buy=input().split()
for i in buy:
    j=name.index(i)
    tt+=float(data[j][-1])
print('total payment',tt)
    

# 0230, 2022-02-24 08:12:45, PP (100%)

a=input().strip()
data=[] ; tt=0 ;n=[]
while a!='q':
    name,p=a.split()
    data.append([name,p])
    n.append(name)
    a=input().strip()
buy=input().split()
for i in buy:
    j=n.index(i)
    tt+=float(data[j][-1])
print('total payment',tt)
    


# 0231, 2022-02-24 08:08:25, P- (50%)

q = input().split()
y = []
q[1] = float(q[1])
y.append(q)

while q[0] != "q" :
    q = input().split()
    if q[0] != "q" :
        q[1] = float(q[1])
    y.append(q)
p = 0
check = input().split()
for i in y :
    if i[0] in check :
        p += float(i[1])
        
        
print("total payment", p)
# 0232, 2022-02-24 08:12:58, PP (100%)

q = input().split()
y = []
q[1] = float(q[1])
y.append(q)

while q[0] != "q" :
    q = input().split()
    if q[0] != "q" :
        q[1] = float(q[1])
    y.append(q)
p = 0
check = input().split()
for e in check :
    for i in y :
        if i[0] == e  :
            p += float(i[1])
        
        
print("total payment", p)

# 0233, 2022-02-24 08:09:58, -- (0%)

l=[]
while 1 :
    a=input()
    if a=='q' :
        break
    else:
        l.append(a.split())

check=[i for i in input().split()]
data1=[]
for i in range(len(l)):
    data1.append(l[i][0])
data2=[]
for i in range(len(l)):
    data2.append(float(l[i][1]))

all_price=[]
for i in range(len(check)):
    price=data2[data1.index(check[i])]
    all_price.append(price)

print(sum(all_price))

# 0234, 2022-02-24 08:10:20, PP (100%)

l=[]
while 1 :
    a=input()
    if a=='q' :
        break
    else:
        l.append(a.split())

check=[i for i in input().split()]
data1=[]
for i in range(len(l)):
    data1.append(l[i][0])
data2=[]
for i in range(len(l)):
    data2.append(float(l[i][1]))

all_price=[]
for i in range(len(check)):
    price=data2[data1.index(check[i])]
    all_price.append(price)

print('total payment',sum(all_price))

# 0235, 2022-02-24 08:08:50, -- (0%)

items = []
total = 0
while True:
    a = input().split()
    if a == ['q']:
        break
    items.append(a)
want = input().split()

for i in range(len(want)):
    for k in range(len(items)):
        if want[i] == items[k][0]:
            total += float(items[k][1])



print(items)
print(want)
print('total payment', total)
# 0236, 2022-02-24 08:10:34, PP (100%)

items = []
total = 0
while True:
    a = input().split()
    if a == ['q']:
        break
    items.append(a)
want = input()
want2 = want.split()
for i in range(len(want2)):
    for k in range(len(items)):
        if want2[i] == items[k][0]:
            total += float(items[k][1])

print('total payment', total)

# 0237, 2022-02-24 08:07:17, compilation error (0%)

x = input()
m = True
d = []
while m :
  if x == 'q' :
    break
  name,price = x.split()
  d.append([name,price])
c = input().split()
total = 0
for e in c :
  for i in range(len(d)) :
    if e = d[i][0] :
      total += float(d[i][1])
print('total payment',total)


# 0238, 2022-02-24 08:10:00, PP (100%)

x = input()
m = True
d = []
while m :
  if x == 'q' :
    break
  name,price = x.split()
  d.append([name,price])
  x = input()
c = input().split()
total = 0
for e in c :
  for i in range(len(d)) :
    if e == d[i][0] :
      total += float(d[i][1])

print('total payment',total)

# 0239, 2022-02-24 08:11:19, -x (0%)

e = input()
name = []
price = []
while e != 'q':
    w = e.split()
    name.append(w[0])
    price.append(float(w[1]))
    e = input()
buy = input().split()
total = 0
for i in range(len(buy)):
    if buy[i] in name:
        ind = name.index(buy[i])
        total += price[i]
print('total payment', total)
# 0240, 2022-02-24 08:12:00, PP (100%)

e = input()
name = []
price = []
while e != 'q':
    w = e.split()
    name.append(w[0])
    price.append(float(w[1]))
    e = input()
buy = input().split()
total = 0
for i in range(len(buy)):
    if buy[i] in name:
        ind = name.index(buy[i])
        total += price[ind]
print('total payment', total)




# 0241, 2022-02-24 08:15:12, xx (0%)

x = input()
h = 0
p = []
q = []
while true:
    w,e = x.split()
    p.append(w)
    q.append(float(e))
    x = input()
data = input().split()


for i in data:
    h += q[p.index(i)]
print('total payment ' + str(h))
# 0242, 2022-02-24 08:15:46, PP (100%)

x = input()
h = 0
p = []
q = []
while x != 'q':
    w,e = x.split()
    p.append(w)
    q.append(float(e))
    x = input()
data = input().split()


for i in data:
    h += q[p.index(i)]
print('total payment ' + str(h))

# 0243, 2022-02-24 08:11:33, xx (0%)

x=input()
lis=[]
price=[]
total=0
while x!= 'q':
    name,cost=x.split()
    lis.append([name,cost])
    x=input()

y=input().split()
for i in range (len(lis)):
    for e in y:
        if e in lis[i]:
            k=lis[i]
            price.append(k[1])
for i in price:
    i1=int(i)
    total+=i1
print('total payment'+str(total))

        
    

# 0244, 2022-02-24 08:12:52, PP (100%)

x=input()
lis=[]
price=[]
total=0
while x!= 'q':
    name,cost=x.split()
    lis.append([name,cost])
    x=input()

y=input().split()
for i in range (len(lis)):
    for e in y:
        if e in lis[i]:
            k=lis[i]
            price.append(k[1])
for i in price:
    i1=float(i)
    total+=i1
print('total payment'+' '+str(total))

        
    


# 0245, 2022-02-24 08:11:16, xx (0%)

alist = []
blist = []


while True:
    w = input().split()
    if w == ['q']:
        break
    else:
        x,y = w
        alist.append(x)
        blist.append(y)
sum=0
cart = input().append()
for i in range(len(cart)):
    e = cart[i]
    m = x.index(e)
    mm = y[m]
    sum += mm

    
print('total payment', sum)


# 0246, 2022-02-24 08:13:58, PP (100%)

alist = []
blist = []


while True:
    w = input().split()
    if w == ['q']:
        break
    else:
        x,y = w
        alist.append(x)
        blist.append(y)

sum=0
cart = input().split()
for i in range(len(cart)):
    e = cart[i]
    m = alist.index(e)
    mm = blist[m]
    sum += float(mm)

    
print('total payment', sum)



# 0247, 2022-02-24 08:08:55, P- (50%)

x = input()
y = []
k = []
while x != 'q':
    x = x.split()
    y.append(x[0])
    k.append(float(x[1]))
    x = input()

z = input().split()
i = 0 
for j in y:
    if j in z:
        i += k[y.index(j)]

print('total payment',i)
# 0248, 2022-02-24 08:15:04, PP (100%)

n = input()
product = []
value = []
while n != 'q' :
    n1,n2 = n.split()
    product.append(n1)
    n2 = float(n2)
    value.append(n2)
    n = input()
sum = 0
name = input().split()
for e in name :
    if e in product :
        sum += value[product.index(e)]
print('total payment ',sum)

# 0249, 2022-02-24 08:06:16, -- (0%)

x = input()

list = []

while x!='q':
  list.append(x.split())
  x = input()


buy = input().split()

sum = 0

for e in buy:
  for i in range(len(list)):
    if e==list[i][0]:
      sum += float(list[i][1])

print(sum)
# 0250, 2022-02-24 08:07:23, PP (100%)

x = input()

list = []

while x!='q':
  list.append(x.split())
  x = input()


buy = input().split()

sum = 0

for e in buy:
  for i in range(len(list)):
    if e==list[i][0]:
      sum += float(list[i][1])

print('total payment',sum)

# 0251, 2022-02-24 08:12:51, -- (0%)

x = input() ; a = [] ; b = [] ; sum = 0
while x != 'q':
  d = x.split()
  a.append(d[0])
  b.append(float(d[1]))
  x = input()
n = input().split()
for e in n:
  if e in a:
    j = a.index(e)
    sum += b[j]
print('total payment 177.625', sum) 
# 0252, 2022-02-24 08:13:05, PP (100%)

x = input() ; a = [] ; b = [] ; sum = 0
while x != 'q':
  d = x.split()
  a.append(d[0])
  b.append(float(d[1]))
  x = input()
n = input().split()
for e in n:
  if e in a:
    j = a.index(e)
    sum += b[j]
print('total payment', sum)

# 0253, 2022-02-24 08:09:09, -- (0%)

x = input().split()
name = []
price = []
c = 0
while x[0] != "q":
    name.append(x[0])
    price.append(float(x[1]))
    x = input().split()
y = input().split()
for i in range(len(y)):
    if y in name:
        b = name.index(y[i])
    
        c += price[b]
print("total payment ", c)
# 0254, 2022-02-24 08:12:09, PP (100%)

x = input().split()
name = []
price = []
c = 0
while x[0] != "q":
    name.append(x[0])
    price.append(float(x[1]))
    x = input().split()
y = input().split()
for i in range(len(y)):
    if y[i] in name:
        b = name.index(y[i])
        c += price[b]
print("total payment ", c)

# 0255, 2022-02-24 08:10:54, PP (100%)

l = []
r = []
i = input().split()
while i[0] != 'q':
    l.append(i[0])
    r.append(i[1])
    i = input().split()
i = input().split()

def fin(name):
    for i in range(len(l)):
        if l[i] == name:
            return i
    return -1

s=0
for j in i:
    s += float(r[fin(j)])
print('total payment',s)
# 0256, 2022-02-24 08:12:29, PP (100%)

lis_nam = []
lis_pri = []
inp = input().split()
while inp[0] != 'q':
    lis_nam +=[inp[0]]
    lis_pri +=[inp[1]]
    inp = input().split()
inp = input().split()
sum=0
for j in inp:
    k = 0
    for l in range(len(lis_nam)):
        if lis_nam[l] == j:
            k = l
            break
    sum += float(lis_pri[k])
print('total payment',sum)

# 0257, 2022-02-24 08:12:41, -- (0%)

price = []
name= []
test = input()
while test != 'q':
    test = test.split()
    name.append(test[0])
    price.append(float(test[1]))
    test = input()
buy = input().split()
sum=0
for i in buy:
    sum+=price[name.index(i)]

print(sum)


# 0258, 2022-02-24 08:13:49, PP (100%)

price = []
name= []
test = input()
while test != 'q':
    test = test.split()
    name.append(test[0])
    price.append(float(test[1]))
    test = input()
buy = input().split()
sum=0
for i in buy:
    if i in name:
        sum+=price[name.index(i)]
print("total payment",sum)



# 0259, 2022-02-24 08:11:31, -- (0%)

l = []
while(True):
    s = input().split()
    if s[0] == 'q':
        break
    l.append([s[0], float(s[1])])
sum = 0
q = input().split()
for i in q:
    for j in l:
        if j[0] == i:
            sum += j[1]
print(sum)
# 0260, 2022-02-24 08:12:25, PP (100%)

l = []
while(True):
    s = input().split()
    if s[0] == 'q':
        break
    l.append([s[0], float(s[1])])
sum = 0
q = input().split()
for i in q:
    for j in l:
        if j[0] == i:
            sum += j[1]
print('total payment', sum)

# 0261, 2022-02-24 08:10:01, -- (0%)

order = []
inp = input()
name = []
price = []
while(inp != "q"):
  inpl = inp.split()
  name += [inpl[0]]
  price += [inpl[1]]
  inp = input()
order = input().split()
N=len(order)
x=0
pricelist=0
while(x<N):
  search = order[x]
  p = name.index(search)
  pricelist += float(price[p])
  x+=1
print(pricelist)
# 0262, 2022-02-24 08:11:09, PP (100%)

order = []
inp = input()
name = []
price = []
while(inp != "q"):
  inpl = inp.split()
  name += [inpl[0]]
  price += [inpl[1]]
  inp = input()
order = input().split()
N=len(order)
x=0
pricelist=0
while(x<N):
  search = order[x]
  p = name.index(search)
  pricelist += float(price[p])
  x+=1
print("total payment", pricelist)

# 0263, 2022-02-24 08:08:34, -- (0%)

data = []
temp = input()
while(temp != "q"):
    name,price = temp.split()
    data.append([name,float(price)])
    temp = input()
total = 0
buy = input().split()
for x in buy:
    for i in range(len(data)):
        if(data[i][0] == x):
            total += data[i][1]
            break
print("total payment %f" %total) 
# 0264, 2022-02-24 08:11:20, PP (100%)

data = []
temp = input()
while(temp != "q"):
    name,price = temp.split()
    data.append([name,float(price)])
    temp = input()
total = 0
buy = input().split()
for x in buy:
    for i in range(len(data)):
        if(data[i][0] == x):
            total += data[i][1]
            break
print("total payment ",end='')
print(total)

# 0265, 2022-02-24 08:10:14, -- (0%)

goods = []
price = []
name = input()
while name!='q':
    name = name.split(' ')
    goods += [name[0]]
    price += [float(name[1])]
    name = input()
buy = input().split(' ')
b = 0
for i in buy:
    b+=price[goods.index(i)]
print('total paymaent', b)
# 0266, 2022-02-24 08:10:42, PP (100%)

goods = []
price = []
name = input()
while name!='q':
    name = name.split(' ')
    goods += [name[0]]
    price += [float(name[1])]
    name = input()
buy = input().split(' ')
b = 0
for i in buy:
    b+=price[goods.index(i)]
print('total payment', b)

# 0267, 2022-02-24 08:14:36, -- (0%)

n=input().split()
a=[]
pri=0
while n!=["q"]:
    a.append([n])
    n=input().split()
na=input().split()
for i in range (len(na)):
    for j in range (len(a)):
        if str(na[i])==str(a[j][0]):
            pri+=float(a[j][1])
print("total payment",pri)
# 0268, 2022-02-24 08:16:15, PP (100%)

n=input().split()
a=[]
pri=0
while n!=["q"]:
    a.append(n)
    n=input().split()
na=input().split()
for i in range (len(na)):
    for j in range (len(a)):
        if str(na[i])==str(a[j][0]):
            pri+=float(a[j][1])
print("total payment",pri)

# 0269, 2022-02-24 08:07:40, -- (0%)

data = []
for i in range(1000):
    a = input().split()
    if a == ['q']:
        break
    data.append(a)
n = input().split()
ans = 0
for i in n:
    for e in data:
        if i == e[0]:
            ans += float(e[1])
print(ans)
    
    
# 0270, 2022-02-24 08:08:27, PP (100%)

data = []
for i in range(1000):
    a = input().split()
    if a == ['q']:
        break
    data.append(a)
n = input().split()
ans = 0
for i in n:
    for e in data:
        if i == e[0]:
            ans += float(e[1])
print('total payment',ans)
    


# 0271, 2022-02-24 08:05:02, -- (0%)

itm=[]
while(1):
    a = input().split()
    if(a[0]=='q'):break
    itm.append(a)
a = input().split()
ans=0
for i in a:
    for j in itm:
        if(i==j[0]):ans+=float(j[1])
print(ans)
# 0272, 2022-02-24 08:05:57, PP (100%)

itm=[]
while(1):
    a = input().split()
    if(a[0]=='q'):break
    itm.append(a)
a = input().split()
ans=0
for i in a:
    for j in itm:
        if(i==j[0]):ans+=float(j[1])
print("total payment",ans)

# 0273, 2022-02-24 08:15:37, xx (0%)

a=input().split()
name=[]
while a!=["q"]:
    name+=[a]
    a=input().split()
buy=input().split()
c=0
price=0
for i in range(len(buy)):
    for c in range(len(name)):
        if buy[i] in name[c][0]:
            price+=int(name[c][1])
print("total payment",price)
# 0274, 2022-02-24 08:16:14, PP (100%)

get = input()
n = []
p = []
while not get == 'q':
    x,y = get.split()
    n += [x]
    p += [float(y)]
    get = input()
buy = input().split()
price = []
for e in buy:
    if e in n:
        price.append(p[n.index(e)])
money = sum(price)
print('total payment '+str(money))

# 0275, 2022-02-24 08:14:05, -- (0%)

goodslist = []
pricelist = []
i = 0

while i in range (300):
    mango = input().split()
    if len(mango) == 1:
        break
    else:
        goods = mango[0]
        goodslist.append(goods)
        price = mango[1]
        pricelist.append(price)
        i += 1
    
goodslist = goodslist
pricelist = [float(e) for e in pricelist]

needs = input().split()
value = 0.0
for i in needs:
    if i in goodslist:
        value = pricelist[goodslist.index(i)]
        value = value+value
        
print("total payment"+" "+str(value))
# 0276, 2022-02-24 08:15:44, PP (100%)

goodslist = []
pricelist = []
i = 0

while i in range (300):
    mango = input().split()
    if len(mango) == 1:
        break
    else:
        goods = mango[0]
        goodslist.append(goods)
        price = mango[1]
        pricelist.append(price)
        i += 1
    
goodslist = goodslist
pricelist = [float(e) for e in pricelist]

needs = input().split()
value = 0.0
for i in needs:
    if i in goodslist:
        yes = pricelist[goodslist.index(i)]
        value = value+yes
        
print("total payment"+" "+str(value))

# 0277, 2022-02-24 08:09:38, -- (0%)

l1 = []
sale = []
total = 0
inp = input().split()
while inp[0] != 'q' :
  l1.append(inp[0])
  sale.append(inp[1])
  inp = input().split()
print(l1)
print(sale)
iwant = input().split()
for i in iwant :
  x = l1.index(i)
  total += float(sale[x])

print("total payment",total)
# 0278, 2022-02-24 08:09:52, PP (100%)

l1 = []
sale = []
total = 0
inp = input().split()
while inp[0] != 'q' :
  l1.append(inp[0])
  sale.append(inp[1])
  inp = input().split()
  
iwant = input().split()
for i in iwant :
  x = l1.index(i)
  total += float(sale[x])

print("total payment",total)

# 0279, 2022-02-24 08:04:23, -- (0%)

nam = []
prc = []
tot = 0

while True:
  s = input()
  if s != 'q':
    t = s.split()
    nam.append(t[0])
    prc.append(float(t[1]))
  else:
    break

cart = input().split()

for item in cart:
  if item in nam:
    tot += prc[nam.index(item)]

print(tot)
    
# 0280, 2022-02-24 08:06:46, PP (100%)

nam = []
prc = []
tot = 0

while True:
  s = input()
  if s != 'q':
    t = s.split()
    nam.append(t[0])
    prc.append(float(t[1]))
  else:
    break

cart = input().split()

for item in cart:
  if item in nam:
    tot += prc[nam.index(item)]

print('total payment', tot)


# 0281, 2022-02-24 08:14:56, PP (100%)

a = [] ; n = input()
while n != 'q':
    c = n.split()
    a.append(c)
    n = input()
buy = input().split()
pay = 0
for i in range(len(buy)):
    for j in range(len(a)):
        if buy[i] in a[j] :
            pay += float(a[j][1])
print('total payment',pay)
# 0282, 2022-02-24 08:15:52, PP (100%)

a = [] ; n = input()
while n != 'q':
    b = n.split()
    a.append(b)
    n = input()
buy = input().split()
pay = 0
for i in range(len(buy)):
    for j in range(len(a)):
        if buy[i] in a[j] :
            pay += float(a[j][1])
print('total payment',pay)

# 0283, 2022-02-24 08:11:42, PP (100%)

Name = []
Price = []

while True:
    n = input().split()
    if n[0] == 'q':
        break
    Name.append(n[0])
    Price.append(n[1])
l = input().split()
payment = 0
for i in l:
    a = Name.index(i)
    payment += float(Price[a])
print('total payment', payment)
    
    

# 0284, 2022-02-24 08:16:04, PP (100%)

Name = []
Price = []

while True:
    n = input().split()
    if n[0] == 'q':
        break
    Name.append(n[0])
    Price.append(n[1])
l = input().split()
payment = 0
for i in l:
    a = Name.index(i)
    payment += float(Price[a])
print('total payment', payment)

# 0285, 2022-02-24 08:15:56, xx (0%)

d = []
x = input().split()

while x != "q": 
    a = float(x[1])
    d += str(a)
    x = input().split()

out = input().split()
for i in range(len(out)):
    print("total payment",d)


# 0286, 2022-02-24 08:16:47, PP (100%)

store = list()  
inp = input().strip()
while inp != 'q':
    inp = inp.split()
    store += [inp[0], float(inp[1])]
    inp = input().strip()

buys = input().strip().split()
price = 0
for b in buys:
    idx = store.index(b)
    price += store[idx + 1]
print("total payment", price)

# 0287, 2022-02-24 08:10:58, PP (100%)

i=input()
a=[]
b=[]
e=0
while i != 'q':
    i=i.split()
    a.append(i[0])
    b.append(i[1])
    i=input()
c=input().split()
for i in range(len(c)):
    if c[i] in a:
        d=a.index(c[i])
        e=e+float(b[d])
    else:
        pass
print('total payment'+' '+ str(e))


# 0288, 2022-02-24 08:11:31, PP (100%)

n = input().split()
name = []
price = []

while True:
    if n == ["q"]:
        break
    name.append(n[0])
    price.append(float(n[1]))
    n = input().split()
    
cal = input().split()
buy = 0

for i in cal:
    n = name.index(i)
    buy += price[n]
    
print("total payment " + str(buy))


# 0289, 2022-02-24 08:14:18, PP (100%)

listtotal=[]
while True:
    x=input()
    if x =='q':
        break
    x=x.split()
    listtotal.append(x)

#print(listtotal)[['alcoholGel', '100.5'], ['mask', '50.25'], ['atk', '75.5'], ['maskA', '50.0'], ['maskB', '67.125'], ['alcoholSpray', '35']]
t=input()
t=t.split()
price=0
for i in range(len(t)):
    for e in listtotal:#['alcoholGel', '100.5']
        if t[i] == e[0]:
            price+=float(e[1])

print('total payment',price)

# 0290, 2022-02-24 08:15:26, PP (100%)

p = input()
x = []
while p!= "q" :
    p = p.split()
    x.append(p)
    p = input()
z = input().split()
total = 0


for e in z :
    for i in x :
        if e == i[0] :
            total += float(i[1])

print("total payment",total)

# 0291, 2022-02-24 08:07:09, PP (100%)

a = "a"
data_mix = []
while a != "q":
  data = input()
  if data == "q" :
    a = "q"
  else :
    data_mix.append(data.split())
buy = input().split()
pay = 0
for i in buy :
  for e in data_mix :
    if e[0] == i :
      pay += float(e[1])
print("total payment "+str(pay))
  


# 0292, 2022-02-24 08:09:59, PP (100%)

s = []
p = input()
while p != "q" :
    a,b = p.split(" ")
    s.append([a,b])
    p = input()
t = []
c = input()
t = c.split(" ")
price = 0
for i in range (len(s)) :
    for j in range (len(t)) :
        if s[i][0] == t[j] :
            price += float(s[i][1])
print("total payment ",price)
        

# 0293, 2022-02-24 08:15:25, PP (100%)

ABC = input()
XYZ = []
total = 0

while ABC != "q":
    XYZ.append(ABC.split())
    ABC = input()
for want in input().split():
    for e in XYZ:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)


# 0294, 2022-02-24 08:08:59, PP (100%)

n = input()
c = []
while n!= "q" :
    n = n.split()
    c.append(n)
    n = input()
want = input().split()
total = 0


for i in range(len(want)) :
    for product,price in c :
        if want[i] == product :
            total += float(price)

print("total payment",total)
    

# 0295, 2022-02-24 08:12:10, PP (100%)

text1=[]
num=0
while True:
    text = input().split()
    if text[0]=="q":
        break
    text1+=text
buy = input().split()
for i in range(len(buy)):
    num+=float(text1[text1.index(buy[i])+1])
print("total payment",num)

# 0296, 2022-02-24 08:12:35, PP (100%)

lists = []
while True:
  x = input().split()
  if x == ["q"]:
    break
  a = x[0]
  b = float(x[1])
  lists.append([a,b])
out = input().split()
total = 0
for x in out:
    for a, b in lists:
        if x == a:
            total += b
print("total payment ", total)

# 0297, 2022-02-24 08:11:19, PP (100%)

a = input().split()
list1 = []
list2 = []
while a != ['q']:
    list1.append(a[0])
    list2.append(a[1])
    a = input().split()

b = input().split()
c = 0
for i in range(len(b)):
    if b[i] in list1:
        index = list1.index(b[i])
        c = c + float(list2[index])
print('total payment', c)
    

# 0298, 2022-02-24 08:07:10, PP (100%)

l = []
while True:
    i = input()
    if i == 'q':
        break
    i = i.split()
    l.append(i)

p = input().split()
n = 0

for e in p:
    for a in l:
        if e == a[0]:
            n+= float(a[1])

print('total payment',n)
            


# 0299, 2022-02-24 08:16:34, PP (100%)

name=input()
buy=[]
cost=[]
while name != 'q':
    name=name.split()
    buy.append(name[0])
    cost.append(float(name[1]))
    name=input()
bought=input().split()
pay=0
for i in bought:
    a=buy.index(i)
    pay+=cost[a]
print('total payment',pay)


# 0300, 2022-02-24 08:07:01, PP (100%)

a = input().split()
b = []
c = []
while a != ['q'] :
    b.append(a[0])
    c.append(a[1])
    a = input().split()
d = input().split()
e = 0
for i in d:
    e += float(c[b.index(i)])   
print('total payment',e)

# 0301, 2022-02-24 08:09:57, PP (100%)

a=input()
x=[]
y=[]
c=0
while a != 'q':
    a=a.split()
    x.append(a[0])
    y.append(float(a[1]))
    a=input()
    
b=input().split()
for i in range(len(b)):
    z=x.index(b[i])
    c+=y[z]
print('total payment',c)


# 0302, 2022-02-24 08:09:10, PP (100%)

a = input()
listt = []
cost = []
summ = []
while a != "q":
  a1,a2 = a.split()
  listt.append(a1)
  cost.append(a2)
  a = input()
b = input().split()
for i in b:
  summ.append(cost[listt.index(i)])
  summ = [float(o) for o in summ]
print("total payment"+" "+str(sum(summ)))


# 0303, 2022-02-24 08:09:34, PP (100%)

t= input()
product = []
cost = 0
price = []
while t != 'q':
    a = t.split()
    product.append(a[0])
    price.append(float(a[1]))
    t = input()
want = input().split()
for i in range(len(want)):
    if want[i] in product:
        cost += price[product.index(want[i])]
print('total payment ' + str(cost))

# 0304, 2022-02-24 08:11:31, PP (100%)

x = input()
name = []
price = []
while x != 'q':
    n, p = x.split()
    name.append(n)
    price.append(float(p))
    x = input()

total = 0
buy = input().split()
for e in buy:
    if e in name:
        total += price[name.index(e)]

print('total payment', total)

# 0305, 2022-02-24 08:07:22, PP (100%)

g = [] ; p = [] 
d = input()
while d != 'q':
    a, b = [e for e in d.split()]
    g.append(a) ; p.append(b)
    d = input()
buy = [e for e in input().split()]
s = []
all = []
for e in buy:
    j = g.index(e)
    # if e not in :
    all.append(float(p[j]))
# t = 0
print('total payment',sum(all))

# 0306, 2022-02-24 08:14:06, PP (100%)

x = input()
z = []
a = []
while x != 'q' :
    y = x.split()
    pro = y[0]
    pri = float(y[1])
    z.append(pri)
    a.append(pro)
    x = input()
b = input().split()
t = 0.0
for e in b :
    p = a.index(e)
    t += z[p]
print('total payment', t)

# 0307, 2022-02-24 08:05:47, PP (100%)

data = []
pricedata = []
a = input()
while a != "q":
    name,price = a.split()
    price = float(price)
    data.append(name)
    pricedata.append(price)
    a = input()
buy = [x for x in input().split()]
final = 0
for i in range(len(buy)):
    k = data.index(buy[i])
    final += pricedata[k]
print("total payment",final)

# 0308, 2022-02-24 08:14:07, PP (100%)

name=[]
price=[]
x=input()
while x != 'q':
    a,b=x.split()
    name.append(a)
    price.append(float(b))
    x=input()
y=input().split()
m=0
for e in y:
    if e in name:
        i = name.index(e)
        m+=price[i]
print('total payment', m)   

# 0309, 2022-02-24 08:03:01, PP (100%)

item_price = dict()
while True:
    i = input()
    if i == 'q':
        break
    item, price = i.split()
    price = float(price)
    item_price[item] = price
total = 0
for i in input().split():
    total += item_price[i]
print('total payment {}'.format(total))

# 0310, 2022-02-24 08:09:03, PP (100%)

a = input().split()
l = []
total = 0
while a[0] != 'q':
    l.append(a[0])
    l.append(a[1])
    a = input().split()
b = input().split()
for i in range(len(b)):
    if b[i] in l:
        p = l.index(b[i])
        total += float(l[p+1])
print('total payment',total)

# 0311, 2022-02-24 08:11:24, PP (100%)

n = input()
a = []
s = 0
while n != 'q':
    a.append(n.split())
    n = input()
buy = input().split()
for e in buy:
    for i in range(len(a)):
        if e == a[i][0]:
            s += float(a[i][1])
print('total payment', s)


# 0312, 2022-02-24 08:09:40, PP (100%)

menu = input()
Name = []
price = []
while menu != 'q':
    a,b=menu.split()
    Name.append(a)
    price.append(b)
    menu = input()
# print(Name,price)
what = input().split()
total = 0
for ch in what:
    total += float(price[Name.index(ch)])
print('total payment {}'.format(total))
# print(name.index('maskB'))



# 0313, 2022-02-24 08:10:56, PP (100%)

shop = input()
pri = 0
name = []
price = []
while shop != 'q' :
    shop = shop.split()
    name.append(shop[0])
    price.append(float(shop[1]))
    shop = input()
buy = input().split()
for i in buy:
    for y in name:
        if i == y :
            num = name.index(y)
            pri += price[num]
print('total payment',pri)
            


# 0314, 2022-02-24 08:09:34, PP (100%)

x = input()
name = []
price = []
while x != 'q':
    if x=='q':
        break
    else:
        y = x.split(' ')
        name.append(y[0])
        price.append(y[1])
        x = input()
        
buy = input().split(' ')
prli = []
for i in range(len(buy)):
    if buy[i] in name:
        g = name.index(buy[i])
        prli.append(price[g])
prli = [float(p) for p in prli]
gg = sum(prli)
print('total payment', gg)


# 0315, 2022-02-24 08:07:52, PP (100%)

a = input()
item = []
price = []
while a != "q":
  x,y = a.split()
  item.append(x)
  price.append(y)
  a = input()
order = input().split()
t = 0
for i in range(len(order)):
  b = item.index(order[i])
  t += float(price[b])
print("total payment " + str(t))

# 0316, 2022-02-24 08:13:10, PP (100%)

me = input()
mel = []
total = 0

while me != "q":
    mel.append(me.split())
    me = input()
for want in input().split():
    for e in mel:
        if want == e[0]:
            total += float(e[1])
            break
print("total payment", total)

# 0317, 2022-02-24 08:13:34, PP (100%)

input1=input()
itemlist=[]; price=[]
hm=0
while input1 != "q":
    itemlist.append(input1.split()[0])
    price.append(float(input1.split()[1]))
    input1=input()
ans = input().split()
for _ in range(len(ans)):
    hm+=price[itemlist.index(ans[_])]
print("total payment",hm)

# 0318, 2022-02-24 08:13:21, PP (100%)

prod = []
pric = []
x = input()
while x != 'q' :
    x = x.split()
    prod.append(x[0])
    pric.append(float(x[1]))
    x = input()

tot = 0.0
buy = [e for e in input().split()]
for e in buy :
    if e in prod :
        i = prod.index(e)
        tot += pric[i]
print('total payment ' + str(tot))

# 0319, 2022-02-24 08:09:55, PP (100%)

stuff = []

while True:
    s = input()
    if s == 'q':
        break
    else:
        name, price = s.split()
        stuff.append([name, float(price)])

l = [i for i in input().split()]
total = 0
for i in range(len(l)):
    for k in range(len(stuff)):
        if l[i] in stuff[k]:
            total += stuff[k][1]
print('total payment',total)

# 0320, 2022-02-24 08:07:23, PP (100%)

inp = input()
a = []
b = []
s = 0
while inp != 'q':
    c = inp.split()
    a.append(c[0])
    b.append(float(c[1]))
    inp = input()

ans = input().split()

for i in ans:
    if i in a:
        s += b[a.index(i)]

print('total payment', s)

# 0321, 2022-02-24 08:06:55, PP (100%)

b = []
a = input()
s = 0
while a != 'q':
  a = a.split()
  b.append(a)
  a = input()
c = input().split()
for i in range(len(c)):
  for a1,a2 in b :
    if a1 == c[i]:
      s += float(a2)
print('total payment', s)

# 0322, 2022-02-24 08:04:32, PP (100%)

x = input()
s = []
while x != "q" :
    s.append(x.split())
    x = input()
a = input().split()
c = 0
for i in range(len(s)) :
    for e in range(len(a)) :
        if a[e] == s[i][0] :
            c += float(s[i][1])
print("total payment", c)

# 0323, 2022-02-24 08:16:23, PP (100%)

n = input()
name_total = []
price_total = []
total = 0
while n!='q':
    name,price = n.split()
    n= input()
    name_total.append(name)
    price_total.append(float(price))
z = input().split()
for i in z:
    total+= price_total[name_total.index(i)]
print("total payment",total)

# 0324, 2022-02-24 08:09:09, PP (100%)

x = '0'
name= []
price =[]
while x!= 'q':
    x = input().split()
    if 'q' in x :
        break
    name.append(x[0])
    price.append(float(x[1]))
what = input().split()
total_price = 0
for i in range(len(what)):
    j = name.index(what[i])
    total_price += price[j]
    
print('total payment '+str(total_price))

# 0325, 2022-02-24 08:07:44, PP (100%)

p = []
lp = input()
while lp != 'q':
    p.append(lp)
    lp = input()
order = input().split()
t = 0
for i in order:
    for j in p:
        if i in j:
            t+=float(j.split()[1])
print('total payment',t)

# 0326, 2022-02-24 08:10:34, PP (100%)

buy = []
summ = 0
while True:
    a = input().split()
    if a[0] == 'q':
        break
    else:
        buy.append(a[0])
        buy.append(a[1])
        a = []
b = input().split()
i = 0
while i < len(b):
    ind = buy.index(b[i])
    ii = ind + 1
    summ += float(buy[ii])
    i += 1
print('total payment',summ)

# 0327, 2022-02-24 08:06:34, PP (100%)

name = []
price = []
n = input()
while n != "q":
    name.append(n.split()[0])
    price.append(float(n.split()[1]))
    n = input()
s = input().split()
sp = 0
for e in s:
    sp += price[name.index(e)]
print("total payment", sp)

# 0328, 2022-02-24 08:12:24, PP (100%)

a = []
b = input()
while b != 'q':
    c = b.split()
    a.append(c)
    b = input()
want = input().split()
total = 0
for i in range(len(want)):
    for j in range(len(a)):
        if want[i] in a[j] :
            total += float(a[j][1])
print('total payment',total)
        
        

# 0329, 2022-02-24 08:10:22, PP (100%)

x = input()
lists = []
while x != 'q' :
    a,b = x.split()
    b = float(b)
    lists.append(a)
    lists.append(b)
    x = input()
y = input().split()
sums = 0
for i in range(len(y)) :
    k = lists.index(y[i])
    sums += lists[k+1]
print('total payment',sums)

# 0330, 2022-02-24 08:06:55, PP (100%)

dd = {}
while True:
    x = input().strip()
    if x == 'q':
        break
    x = x.split()
    dd.update({x[0]:x[1]})
y = input().split()
#print(dd)
sum =0
for i in y:
    sum += float(dd[i])
#print(sum)
print('total payment '+str(sum))

# 0331, 2022-02-24 08:07:25, PP (100%)

l=[]
a=0
while a!="q":
    a=input()
    if a != "q":
        a=a.split()
        l.append(a)
b=input().split()
s=0.0
for w in b:
    for [n,p] in l:
        if w==n:
            s+=float(p)
print("total payment",s)
    

# 0332, 2022-02-24 08:12:33, PP (100%)

x = input()
l = []
while x != 'q' :
    a,b = x.split()
    l.append([a,float(b)])
    x = input()

n = [str(e) for e in input().split()]


z = 0
for i in range(len(n)) :
    for q,w in l :
            if n[i] == q :
                z += w
    
print('total payment',z)
        

# 0333, 2022-02-24 08:06:01, PP (100%)

x = input()
goods = []
price = []
while x != "q" :
    t = x.split()
    goods.append(t[0])
    price.append(float(t[1]))
    x = input()
need = input().split()
summ = 0
for i in range(len(need)) :
    if need[i] in goods :
        j = goods.index(need[i])
        summ += price[j]
print("total payment", summ)

# 0334, 2022-02-24 08:14:16, PP (100%)

def get_list():
    name = []
    price = []
    while True:
        x = input()
        if x == 'q':
            break
        name1, price1 = x.split()
        name.append(name1)
        price.append(float(price1))
    return name, price

def find_total_payment(name, price, list_of_items):
    total_payment = 0
    for i in list_of_items:
        for j in range(len(name)):
            if i == name[j]:
                total_payment += price[j]
    return total_payment

def main():
    name, price = get_list()
    list_of_items = input().split()
    total_payment = find_total_payment(name, price, list_of_items)
    print('total payment', total_payment)

main()

# 0335, 2022-02-24 08:11:43, PP (100%)

x = input()
p = []
q = []
while x != 'q':
    a,b = x.split()
    p.append(a)
    q.append(float(b))
    x = input()
y = input().split()
price = 0
for i in y:
    price += q[p.index(i)]
print('total payment',price)

# 0336, 2022-02-24 08:07:50, PP (100%)

goods = []
prize = []
x = input()
while x != 'q':
    y = x.split(' ')
    goods.append(y[0])
    prize.append(float(y[1]))
    x = input()
order = input().split()
total = 0
for e in order:
    z = goods.index(e)
    total += prize[z]
print('total payment',total)

# 0337, 2022-02-24 08:06:37, PP (100%)

x=input()
k=[]
t=0
while x!='q':
    k.append(x.split())
    x=input()
p=input().split()
for i in range(len(p)):
    for n in range(len(k)):
        if p[i]==k[n][0]:
            t+=float(k[n][1])
print('total payment '+str(t))

# 0338, 2022-02-24 08:03:14, PP (100%)

price_list = []
food_list = []
while True:
    x = input()
    if x == 'q':
        break
    a = x.split()
    price_list.append(float(a[1]))
    food_list.append(a[0])
orders = input().split()
res = sum(price_list[food_list.index(f)] for f in orders)
print("total payment", res)


# 0339, 2022-02-24 08:07:04, PP (100%)

x = [input()]
while x != 'q':
    y = input()
    if y != 'q':
        x.append(y)
    else:
        break
buy = input().split()
z = []
for i in range(len(x)):
    x[i] = x[i].split()
for i in range(len(buy)):
    for a,b in x:
        if buy[i] == a:
            z.append(b)
for i in range(len(z)):
    z[i] = float(z[i])
zz = 0
for i in range(len(z)):
    zz += z[i]
print("total payment", zz)


# 0340, 2022-02-24 08:10:37, PP (100%)

x = input()
n = []
p = []
while x!= "q":
    name,price = x.split()
    n.append(name)
    
    p.append(float(price))
    x = input()
k=0   
y = input().split()
for e in y:
    if e in n:
        u = n.index(e)
        k += p[u]
print("total payment"+" " +str(k))



# 0341, 2022-02-24 08:10:54, PP (100%)

list = []
total = 0.0
while True:
    a = input().split()
    if a == ['q']:
        break
    list.append(a)
cart = input().split()
for name,price in list:
    for order in cart:
        if name == order:
            total += float(price)
print('total payment',total)

# 0342, 2022-02-24 08:08:50, PP (100%)

n=[]
p=[]
while True:
    x = input().split()
    if x[0]=='q':
        break
    n.append(x[0])
    p.append(float(x[1]))
f = input().split()
c=0
for i in f:
    m = n.index(i)
    c+= p[m]
print('total payment',c)

# 0343, 2022-02-24 08:07:30, PP (100%)

x= input()
r=[]
e=[]
while x!="q":
    a= x.split()
    r.append(a[0])
    e.append(a[1])
    x= input()
z= input().split()
d=0
for i in range(len(z)):
    if z[i] in r:
        w= r.index(z[i])
        d= d+ float(e[w])
print("total payment "+str(d))
        



# 0344, 2022-02-24 08:06:57, PP (100%)

name=[];price=[];pay=0.0
while True:
    a = input().split()
    if a[0]=='q':
        break
    else:
        name.append(a[0])
        price.append(float(a[1]))
b = input().split()
for e in b:
    if e in name:
        c=name.index(e)
        pay+=price[c]
print('total payment',pay)

# 0345, 2022-02-24 08:14:13, PP (100%)

x = input()
xs = []
y = 0

while x != "q":
    xs.append(x.split())
    x = input()
for total in input().split():
    for e in xs:
        if total == e[0]:
            y += float(e[1])
            break
print('total payment', y)


# 0346, 2022-02-24 08:08:34, PP (100%)

ip = input()
item = []
price = []
while ip != 'q':
    i,p = ip.split()
    item.append(i)
    price.append(float(p))
    ip = input()

buy = input().split()
sum = 0
for i in buy:
    x = item.index(i)
    sum += price[x]

print('total payment', sum)


# 0347, 2022-02-24 08:07:28, PP (100%)

Data, Store, Sum = input(), [], 0

while Data != "q":
    Store.append(Data.split())
    Data = input()
for want in input().split():
    for e in Store:
        if want == e[0]:
            Sum += float(e[1])
            break
print("total payment", Sum)

# 0348, 2022-02-24 08:12:47, PP (100%)

n=input()
r=[]
a=[]
while n != 'q' :
    e=n.split()
    r.append(e[0])
    a.append(float(e[1]))
    n=input()
o=input().split()
t=[]
for i in range(len(o)):
    if o[i] in r :
        d=r.index(o[i])
        s=a[d]
        t.append(s)
print('total payment'+' '+str(sum(t)))

# 0349, 2022-02-24 08:09:51, PP (100%)

alist=[]
blist=[]
while True :
    x=input()
    if x=='q':
        break
    else:
        a,b=x.split()
        alist.append(a)
        blist.append(float(b))
y=input().split()
p=0
for i in y:
    p+=blist[alist.index(i)]
print('total payment',p)

# 0350, 2022-02-24 08:13:46, PP (100%)

data1=[]
data2=[]
x=input()
a,b=x.split()
while x != 'q' :
    a,b=x.split()
    data1.append(a)
    data2.append(b)
    x=input()
    
y=input().split()
sum=0
for i in y:
    for o in range (len(data1)):
      if i ==  data1[o]:
          sum+=float(data2[o])
print('total payment '+str(sum))
     


# 0351, 2022-02-24 08:04:52, PP (100%)

lst = []
while True:
    n = input()
    if n == 'q':
        break
    name, price = n.split()
    lst.append([name, float(price)])

targets = input().split()

total_price = 0
for target in targets:
    for name, price in lst:
        if target == name:
            total_price += price

print('total payment {}'.format(total_price))

# 0352, 2022-02-24 08:12:20, PP (100%)

a = input()
b = []
while a != "q" :
    b.append(a.split())
    a = input()
c = input().split()
total = 0
for i in range(len(c)) :
    for n in range(len(b)) :
        if c[i] == b[n][0] :
            total += float(b[n][1])
print('total payment', total)

# 0353, 2022-02-24 08:13:01, PP (100%)

z = input().split()
x = []
y = []
x.append(z[0])
y.append(z[1])
while z != ["q"]:
    z = input().split()
    if z != ["q"]:
        x.append(z[0])
        y.append(z[1])
buy = input().split()
a = 0
for i in range(len(buy)):
    a += float(y[x.index(buy[i])])
print("total payment",a)

# 0354, 2022-02-24 08:13:57, PP (100%)


x = []
while True :
    shop = input()   
    if shop == 'q' :
        break
    else :
        shop = shop.split()
        shop[1] = float(shop[1])
        x += [[shop[0],shop[1]]]
tt=0       
buy = input().split()
for i in range (len(x)) :
        for j in range(len(buy)) :
            l = x[i]
            if buy[j] in l[0] :
                tt+=l[1]

        
print('total payment ',tt)
        



# 0355, 2022-02-24 08:12:07, PP (100%)

x,z = [],[]
y = input()
while y != 'q':
    a = y.split(" ")
    x.append(a[0])
    z.append(float(a[1]))
    y = input()
s = 0
f = input().split()
for i in range(len(f)):
    if f[i] in x:
        d = x.index(f[i])
        s+=z[d]
print('total payment',str(s)) 

# 0356, 2022-02-24 08:16:58, PP (100%)

x = input()
y = []
total = 0
while x != "q":
    y.append(x.split())
    x = input()
for buy in input().split():
    for i in y:
        if buy == i[0]:
            total += float(i[1])
            break
print("total payment", total)


# 0357, 2022-02-24 08:14:19, PP (100%)

allcart = []
n = input()
while n != "q":
    n= n.split()
    name = n[0]
    price = float(n[1])
    allcart.append([name,price])
    n = input()
buycart = input().split()
price = 0
for i in range(len(buycart)):
    for j in range(len(allcart)):
        if buycart[i] == allcart[j][0]:
            price += allcart[j][1]   
print("total payment",price)

# 0358, 2022-02-24 08:15:28, PP (100%)

use = input().split()
if len(use) == 1:
    name = use[0]
else:
    name = use[0]
    price = use[1]
namelist = []
pricelist = []
payment = 0
while name != 'q':
    price = float(price)
    namelist.append(name)
    pricelist.append(price)
    use = input().split()
    if len(use) == 1:
        name = use[0]
    else:
        name = use[0]
        price = use[1]
want = input().split()
for c in want:
    if c in namelist:
        payment += pricelist[namelist.index(c)]
print('total payment',payment)



# 0359, 2022-02-24 08:06:33, PP (100%)

x = input().split()
name = []
price = []
total = 0

while x != ['q'] :
    name.append(x[0])
    price.append(x[1])
    x = input().split()
    
buy = input().split()

for i in buy :
    a = name.index(i)
    total += float(price[a])
    
print('total payment', total)
    


# 0360, 2022-02-24 08:11:35, PP (100%)

a = []
b = []
p = []
c = input().split()
while c[0] != 'q':
    a.append(c[0])
    b.append(c[1])
    c = input().split()

d = input().split()
for e in range(len(b)):
    b[e] = float(b[e])

for i in d:
    if i in a:
        p.append(b[a.index(i)])
print('total payment',sum(p))

# 0361, 2022-02-24 08:07:12, PP (100%)

n = input() ; name = [] ; price = [] ; total = 0
while n != 'q':
    np = n.split()
    name.append(np[0])
    price.append(float(np[1]))
    n = input()
m = input()
for e in m.split():
    if e in name:
        total += price[name.index(e)]
print('total payment', total)

# 0362, 2022-02-24 08:09:58, PP (100%)

x = input()
pro = []
pri = []
while x != "q":
    x = x.split()
    pro.append(x[0])
    pri.append(x[1])
    x = input()

buy = input().split()
sum = 0
for i in range(len(buy)):
    if buy[i] in pro:
        ind = pro.index(buy[i])
        sum+=float(pri[ind])
print("total payment",sum)



# 0363, 2022-02-24 08:06:42, PP (100%)

a = []

while True:
    x = input()
    if x == 'q':
        break
    a.append(x.split())

de = input().split()
c = 0

for e in de:
    for t in a:
        if e in t:
            c += float(t[1])

print('total payment',c)

# 0364, 2022-02-24 08:07:00, PP (100%)

q=input()
a=[]
b=[]
s=0
while q!='q':
    q=[i for i in q.split()]
    a.append(q[0])
    b.append(q[1])
    q=input()
C=input().split()
for i in C:
    s+=float(b[a.index(i)])
print('total payment',s)

# 0365, 2022-02-24 08:06:16, PP (100%)

a = input().split()
item = []
price = []
total = 0
while a[0] != 'q':
    item.append(a[0])
    price.append(a[1])
    a = input().split()
rub = input().split()
for i in rub:
    if i in item:
        total = total + float(price[item.index(i)])
print("total payment",total)

# 0366, 2022-02-24 08:08:47, PP (100%)

order = ""
total = []
while order != ["q"]:
  total.append(order)
  order = input().split()
total = [[float(i[j]) if j == 1 else i[j] for j in range(2)] for i in total[1:]]

buy = []
for i in input().split():
  for j in total:
    if i == j[0]:
      buy.append(j[1])
print("total payment", sum(buy))

# 0367, 2022-02-24 08:09:14, PP (100%)

l = []
p = []
while True :
    prod = input().split()
    if prod[0] == 'q' : break
    l.append(prod[0])
    p.append(float(prod[1]))
buy = input().split()
sPrice = 0
for bProd in buy :
    i = l.index(bProd)
    sPrice += p[i]
print('total payment',sPrice)
    

# 0368, 2022-02-24 08:09:55, PP (100%)

x=input().split()
n=[]
p=[]
while x[0]!="q":
    n.append(x[0])
    p.append(float(x[1]))
    x=input().split()

t=0
y=input().split()
for i in range(len(y)):
    t+=p[n.index(y[i])]

print("total payment"+" "+str(t))

# 0369, 2022-02-24 08:09:23, PP (100%)

itemlist = []
pricelist = []
pay = []

while True:
    x = input()
    if x == 'q':
        break
    else:
        item,price = x.split()
        itemlist.append(item)
        pricelist.append(price)
query = input().split()

for i in range(len(query)):
    if query[i] in itemlist:
        index = itemlist.index(query[i])
        pay.append(float(pricelist[index]))

pay = sum(pay)
print('total payment', pay)

# 0370, 2022-02-24 08:11:01, PP (100%)

n = input()
x = []
y = []
t = 0
while n!='q':
    a,b = n.split()
    n = input()
    x.append(a)
    y.append(float(b))
p = input().split()
for i in p:
    t += y[x.index(i)]
print('total payment',t)

# 0371, 2022-02-24 08:06:07, PP (100%)

a = ''
b = []
while a != 'q':
  a = input()
  b.append(a.split())
c = [e for e in input().split()]
total = 0
for i in c:
    for e in range (len(b)):
        if b[e][0] == i:
            total += float(b[e][1])
print('total payment',total)     

# 0372, 2022-02-24 08:08:11, PP (100%)

name = []
price = []
val = 0

while(1):
    x = input()
    if x=='q':
        break
    else:
        x = x.split()
    name.append(x[0])
    price.append(float(x[1]))
ans = input().split()
for i in ans:
    for j in range(len(name)):
        if i == name[j]:
            val += price[j] 
print("total payment",val)

# 0373, 2022-02-24 08:12:44, PP (100%)

n = input()
free = []
while n != 'q':
    name,price = n.split()
    free.append([name,price])
    n = input()
buy = input().split()
total = 0 
for i in range(len(buy)):
    for e in range(len(free)):
        if buy[i] == free[e][0]:
            total += float(free[e][1])
print('total payment ' + str(total))

# 0374, 2022-02-24 08:12:44, PP (100%)

product = input()
payment = 0
list_product = []
list_price = []
while product != 'q':
  n = product.split()
  list_product.append(n[0])
  list_price.append(n[1])
  product = input()

buy = input().split()
for e in buy:
  for i in range(len(list_product)):
    if e in list_product[i]:
      payment += float(list_price[i])

ans = 'total payment ' + str(payment)
print(ans)



# 0375, 2022-02-24 08:09:35, PP (100%)

data = input()
product = []
price = []

while data != 'q' :
    data = data.split()
    product.append(data[0])
    price.append(data[1])
    data = input()
    
find = input().split()

total = 0

for e in find :
    for i in range(len(product)) :
        if e == product[i] :
            total += float(price[i])
            
print('total payment ' + str(total))

# 0376, 2022-02-24 08:05:59, PP (100%)

n = input().split()
m = []; p = []
while n != ['q']:
    m.append(n[0])
    p.append(float(n[1]))
    n = input().split()
a = input().split()
c = 0
for i in a:
    f = m.index(i)
    c += p[f]
print('total payment ' + str(c))

# 0377, 2022-02-24 08:03:33, PP (100%)

a = []
p = []
while True:
    b = input()
    if b == 'q':
        break
    name, price = b.split()
    a.append(name)
    p.append(float(price))
want = input().split()
pay = 0
for i in want:
    pay += p[a.index(i)]
print('total payment', pay)

# 0378, 2022-02-24 08:05:56, PP (100%)

n = input()
l = []
while n != 'q':
    no = n.split()
    product = no[0]
    price = no[1]
    l.append([product,price])
    n = input()

buy = input().split()
total_price = 0
for i in buy:
    for e in range(len(l)):
        if i == l[e][0]:
            total_price += float(l[e][1])
print('total payment',total_price)
    


# 0379, 2022-02-24 08:05:54, PP (100%)

a = input()
ids = []
price = []
while a != 'q':
    d,e = a.split()
    ids.append(d)
    price.append(float(e))
    a = input()

cost = 0
buy = input().split()
for e in buy:
    i = ids.index(e)
    cost += price[i]

print("total payment", cost)


# 0380, 2022-02-24 08:10:47, PP (100%)

x = input()
name = []
price = []
c = 0
while x != "q":
    a,b = x.split()
    name += [a]
    price += [b]
    x = input()
y = input().split()
for i in range(len(y)):
    for k in range(len(name)):
        if y[i] == name[k]:
            c += float(price[k])
print("total payment",c)

# 0381, 2022-02-24 08:08:00, PP (100%)

d = []
s = 0
x = input()
while x!='q':
    ids,prices = x.split()
    d.append(ids)
    d.append(prices)
    x= input()
    
shop = input().split()
for i in range(len(shop)):
    if shop[i] in d:
        pos=d.index(shop[i])
        s+=float(d[pos+1])
print('total payment',s)

# 0382, 2022-02-24 08:09:53, PP (100%)

data = input()
name = []
price = []
total = 0
lum = 0
while data != "q":
    name.append(data.split()[0])
    price.append(data.split()[1])
    data = input()
    
buy = input().split()
for i in range(len(buy)):
    if buy[i] in name:
        lum = name.index(buy[i])
        total = total + float(price[int(lum)])

print("total payment",total)


# 0383, 2022-02-24 08:09:21, PP (100%)

m = input()
lists = []
while m != 'q':
    m = m.split()
    lists.append(m)
    m = input()

b = input().split()
price = 0
for a in b:
    for z in range(len(lists)):
        if a == lists[z][0]:
            price += float(lists[z][1])
print('total payment', price)

    


# 0384, 2022-02-24 08:13:37, PP (100%)

x = input()
a = []
b = []
while x != 'q':
    x = x.split()
    a.append(x[0])
    b.append(x[1])
    x = input()

            
pay = 0

buy = input().split()

for e in buy :
    for i in range(len(a)):
        if e == a[i] :
            pay += float(b[i])
            
print("total payment " + str(pay))


# 0385, 2022-02-24 08:15:30, PP (100%)

goods = []
price = []
while True:
  l = input().split()
  if l == ["q"]:
    break
  goods.append(l[0])
  price.append(float(l[1]))
buy = input().split()
total = 0
for e in buy:
  i = goods.index(e)
  total += price[i]
print("total payment ",total)

# 0386, 2022-02-24 08:05:56, PP (100%)

t=input()
item=[]
price=[]
value=0
while t!="q":
    x=t.split()
    item.append(x[0])
    price.append(x[1])
    t = input()
order=input().split()
for i in range(len(order)):
    for j in range(len(item)):
        if order[i]==item[j]:
            value+=float(price[j])
print("total payment",value)


# 0387, 2022-02-24 08:11:18, PP (100%)

x=input()
l=[]
total=0
while x!="q":
  x=x.split()
  l.append([x[0],x[1]])
  x=input()
p=input().split()
for c in p:
  for e in l:
    if e[0]==c:
      total+=float(e[1])
      break
print("total payment",total)


# 0388, 2022-02-24 08:08:13, PP (100%)

lst = []
price = []
ans = 0
while True:
    get = input().split()
    if get != ['q']:
        lst.append(get[0])
        price.append(get[1])
    else:
        break
price = [float(e) for e in price]
answer = input().split()
for item in answer:
    if item in lst:
        index = lst.index(item)
        ans += price[index]
print('total payment', ans)

# 0389, 2022-02-24 08:06:21, PP (100%)

a=input().split()
s=[]
s1=[]
v=0
while a[0]!='q':
    s.append(a[0])
    s1.append(a[1])
    a=input().split()
z=input().split()
for i in z:
    v+=float(s1[s.index(i)])
print('total payment',v)


# 0390, 2022-02-24 08:11:34, PP (100%)

p = []
while True:
    a = input()
    if a == "q":break
    b = a.split()
    p.append([b[0],float(b[1])])
p1 = 0
c = input().split()
for k in c:
    for i in range(len(p)):
        if k == p[i][0]:
            p1 += p[i][1]
print("total payment "+ str(p1))

# 0391, 2022-02-24 08:12:26, PP (100%)

x= input()
name=[]
price = []
while x != 'q':
    n,p = x.split()
    name.append(n)
    price.append(p)
    x = input()
sums = 0
q = input().split()
for i in q:
    if i in name:
        a = name.index(i)
        sums += float(price[a])
print('total payment',sums)

# 0392, 2022-02-24 08:13:47, PP (100%)

alllist = []
llist = input()
while llist != 'q':
    alllist.append(llist.split())
    llist = input()

buy = input().split()
mon = 0
for i in buy:
    for j in alllist:
        if i == j[0]:
            mon += float(j[1])
print('total payment', mon)

# 0393, 2022-02-24 08:09:30, PP (100%)

i = input()
a=[]
b=[]
while i!='q':
    x = i.split()
    a.append(x[0])
    b.append(x[1])
    i = input()
c = input().split()
sums = 0
for j in range(len(c)):
    k = a.index(c[j])
    sums+=float(b[k])
print('total payment',str(sums))

# 0394, 2022-02-24 08:12:08, PP (100%)

li = []
t = input()
price = 0
while t!='q':
    li.append(t.split())
    t = input()
prod = input().split()
for e in prod:
    for k in li:
        if e == k[0]:
            price+=float(k[1])
print('total payment',price)

# 0395, 2022-02-24 08:06:16, PP (100%)

c = input().strip()
name = []
price = []
while c != 'q':
    n,p = c.strip().split()
    p = float(p)
    name.append(n)
    price.append(p)
    c = input()
list1 = input().strip().split()
count = 0
for e in list1:
    if e in name:
        count += price[name.index(e)]
print('total payment',count)

# 0396, 2022-02-24 08:12:20, PP (100%)

e = input()
name_goods = []
price = []
while e != 'q':
    x = e.split()
    name_goods.append(x[0])
    price.append(x[1])
    e = input()
buy = input().split()
j = 0
sum_price = 0
for name in buy:
    for i in range(len(name_goods)):
        if name == name_goods[i]:
            sum_price += float(price[i])
        
print('total payment', sum_price)

# 0397, 2022-02-24 08:07:16, PP (100%)

x = input()
list_name = []
list_price = []
while x != 'q':
    x = x.split()
    list_name.append(x[0])
    list_price.append(x[1])
    x = input()
#[['alcoholGel', '100.5'], ['mask', '50.25'], ['atk', '75.5']]
price = 0
for e in input().split():
    price += float(list_price[list_name.index(e)])
print('total payment',price)

# 0398, 2022-02-24 08:12:02, PP (100%)

x = input(); y = []
while x != 'q':
    n,c = x.split()
    y.append([n,float(c)])
    x = input()
z = input().split()
t = 0
for e in z:
    for i in range(len(y)):
        if e == y[i][0]:
            t += y[i][1]
print('total payment', t)

# 0399, 2022-02-24 08:08:34, PP (100%)

x = input()
d = []
while x != "q":
    name, price = x.split()
    d.append([name, price])
    x = input()
buy = input().split()
p = 0
for e in buy:
    for name,price in d:
        if e == name:
            p +=float(price)
print("total payment", p)

# 0400, 2022-02-24 08:14:35, PP (100%)

x = input()
y = []
while x != 'q':
    y += x.split()
    x = input()

z = input().split()
p = 0
for i in z:
    for n in range(len(y)):
        if i == y[n]:
            p += float(y[n+1])

print('total payment', p)

# 0401, 2022-02-24 08:09:55, PP (100%)

x=input().split()
y=[]
z=[]
while x[0] != 'q':
    y.append(float(x[1]))
    z.append(x[0])
    x=input().split()
a=input().split()
p=0
for x in a:
    p+=y[z.index(x)]
print('total payment',p)

# 0402, 2022-02-24 08:10:10, PP (100%)

x = input().split(' ')
y = []
price = []
while x != ['q']:
    y.append(x[0])
    price.append(x[1])
    x = input().split(' ')
z = input().split(' ')
a = 0
for i in z:
    if i in y:
        a += float(price[y.index(i)])
print('total payment ' + str(a))

# 0403, 2022-02-24 08:09:46, PP (100%)

a=input().split()
b=[]
while a!=['q']:
    b.append(a)
    a=input().split()
c=input().split()
d=0
for i in range(len(b)):
    for j in range(len(c)):
        if c[j]==b[i][0]:
            d+=float(b[i][1])
print('total payment',d)

# 0404, 2022-02-24 08:08:06, PP (100%)

a = input().split()
b = []
c = []
k = 0
while a[0] != 'q':
  b.append(a[0])
  c.append(float(a[1]))
  a = input().split()
d = input().split()
for e in d:
  for i in range(len(b)):
    if e == b[i]:
      k += c[i]
print('total payment'+' '+str(k))

# 0405, 2022-02-24 08:09:34, PP (100%)

i = 0
flst = []
while True:
  i = input()
  if i != 'q':
    lst = i.split()
  else:
    break
  flst.append(lst)
blst = input().split()
p = 0.0
for i in range(len(blst)):
  for j in range(len(flst)):
    if flst[j][0] == blst[i]:
      p += float(flst[j][1])
print('total payment '+str(p))

# 0406, 2022-02-24 08:14:11, PP (100%)

t = input().split()
ids = []
grades = []

while t[0] != 'q':
    ids.append(t[0])
    grades.append(t[1])
    t = input().split()
ST = input().split()
l = 0
for i in ST:
    for e in range(len(ids)):
        if i == ids[e]:
            l += float(grades[e])
print('total payment',l)

# 0407, 2022-02-24 08:09:50, PP (100%)

ans = ''
arr = []
while 1:
    s = input()
    if s == 'q':
        break
    arr.append(s.split())
all = input().split()
sum = 0
for i in all:
    for j in arr:
        if i == j[0]:
            sum += float(j[1])
print('total payment ' + str(sum))


# 0408, 2022-02-24 08:08:56, PP (100%)

name=[]
price=[]
input1=input()
while input1!='q':
    x=input1.split()
    name.append(x[0])
    price.append(float(x[1]))
    input1=input()

pay=0
buy=input().split()
for pro in buy:
    Ppay=price[name.index(pro)]
    pay+=Ppay
    
print('total payment '+str(pay))

# 0409, 2022-02-24 08:09:37, PP (100%)

n = input()

goods = []
price = []

while n != 'q':
    n = n.split()
    goods += [n[0]]
    price += [float(n[1])]
    n = input()

m = input().split()

total = 0
for i in range(len(m)):
    if m[i] in goods :
        a = goods.index(m[i])
        total += price[a]

print('total payment'+' '+str(total))

# 0410, 2022-02-24 08:13:34, PP (100%)

item_list = []
while(True):
    item = input()
    if(item == "q"): break
    name,price = item.split()
    item_list.append((name, price))

a = input().split()
sum = 0
for item in a:
    for name,price in item_list:
        if(name == item):
            sum += float(price)
            break
print("total payment",end=' ')
print(sum)

# 0411, 2022-02-24 08:09:48, PP (100%)

name=[]
pri=[]
a=input().split()

while a[0]!="q":
    name.append(a[0])
    pri.append(a[1])
    a=input().split()

total=0.0
buy=input().split()
for i in range (len(buy)):
    if (buy[i] in name):
        n=name.index(buy[i])
        total+=float(pri[n])

print ("total payment",total)

# 0412, 2022-02-24 08:11:29, PP (100%)

s = []
x = input()
while x != 'q' :
    s.append(x.split())
    x = input()
shop = input().split()
pay = 0
for i in range(len(shop)):
    for j in range(len(s)):
        if shop[i] == s[j][0]:
            pay += float(s[j][1])
print('total payment '+str(pay))

# 0413, 2022-02-24 08:13:34, PP (100%)

x = str(input()).split()
ob = []
math = []
price = 0
ob.append(x[0])
math.append(x[1])
while x[0] != 'q':
    
    x = str(input()).split()
    
    if x[0]!= 'q':
        ob.append(x[0])
        math.append(x[1])
y = str(input()).split()
for i in y:
    kk = ob.index(i)
    price+=float(math[kk])
print('total payment',str(price))

# 0414, 2022-02-24 08:08:30, PP (100%)

x = input().split()


    
    
    
y = []    
while x != ['q']:
    y.append(x)
    x = input().split()
    
name = input().split()

c = 0
for i in name:
    for e in range(len(y)):
        
        if i == y[e][0]:
            c += float(y[e][1])
            
print('total payment',c)

# 0415, 2022-02-24 08:08:02, PP (100%)

a=input()
store=[]
money=0
while(a!='q'):
    if ' ' in a:
        a=a.split()
    store.append(a)
    a=input()
buy=input().split()
for e in buy:
    for d in store:
        if e==d[0]:
            money+=float(d[1])
print('total payment',money)


# 0416, 2022-02-24 08:08:30, PP (100%)

s = input()
name = []
price = []
while s != 'q':
  d = s.split()
  name.append(d[0])
  price.append(d[1])
  s = input()
want = input().split()
total = 0
for i in range(len(want)):
  for j in range(len(name)):
    if want[i] == name[j]:
      total += float(price[j])
print('total payment',total)

# 0417, 2022-02-24 08:06:48, PP (100%)

a=[]
b=[]
while True :
    f=input()
    if f=='q' :
        break
    f=f.split()
    a.append(f[0])
    b.append(f[1])
sum=input().split()
o=0
for e in sum :
    o+=float(b[a.index(e)])
print('total payment'+' '+str(o))

# 0418, 2022-02-24 08:15:03, PP (100%)

lis_nam = []
lis_pri = []
inp = input().split()
while inp[0] != 'q':
    lis_nam +=[inp[0]]
    lis_pri +=[inp[1]]
    inp = input().split()
inp = input().split()
sum=0
for j in inp:
    k = 0
    for l in range(len(lis_nam)):
        if lis_nam[l] == j:
            k = l
            break
    sum += float(lis_pri[k])
print('total payment',sum)

# 0419, 2022-02-24 08:09:32, PP (100%)

x=input().split()
prod=[x[0]]
price=[float(x[1])]
while x[0]!='q':
    
    prod.append(x[0])
    price.append(float(x[1]))
    x=input().split()
y=input().split()
sum=0
for i in range (len(y)):
    if y[i] in prod:
        k=prod.index(y[i])
        sum+=price[k]
print('total payment '+str(sum))

# 0420, 2022-02-24 08:09:52, PP (100%)

x = input()
name = []
price = []
while x != 'q':
  name1,price1 = x.split()
  name.append(name1)
  price.append(price1)
  x = input()
m = input().split()
pay = 0
for na in m:
  if na in name:
    i = name.index(na)
    pr = float(price[i])
    pay += pr
print('total payment',pay)

# 0421, 2022-02-24 08:08:15, PP (100%)

x = input()
a = []
b = []

while x != 'q' :
    p1,p2 = x.split()
    a.append(p1)
    b.append(p2)
    x = input()
    
c = input().split()

s = 0

for i in range(len(c)) :
    s = s + float(b[a.index(c[i])])
    
print("total payment", s)
    
    


# 0422, 2022-02-24 08:11:19, PP (100%)

a = ""
b = []
d = 0
while True:
    a = input()
    if a == "q":
        break
    a = a.split()
    b.append(a)

c = input().split()
for i in range(len(c)):
    for j in range(len(b)):
        if c[i] == b[j][0]:
            d += float(b[j][1])
print("total payment",d)



# 0423, 2022-02-24 08:07:46, PP (100%)


name = []
price = []
sum = 0
while True:
    x = input().split()
    if x[0] == 'q':
        break
    else:
        name.append(x[0])
        price.append(x[1])

for i in range(len(price)):
    price[i] = float(price[i])

# print(name,price)
a = input().split()
for i in range(len(a)):
    if a[i] in name:
        pos = name.index(a[i])
        sum += price[pos] 
        
        # print(pos,sum)

print('total payment '+str(sum))

# 0424, 2022-02-24 08:06:50, PP (100%)

# [64_2_PCG_06] 64_2_06_List

product_names = []
product_prices = []

while True:
  x = input()

  if x == 'q':
    break
  
  name, price = x.split()

  product_names.append(name)
  product_prices.append(float(price))


order = input().split()

cost = 0

for o in order:
  if o in product_names:
    cost += product_prices[product_names.index(o)]

print('total payment', cost)

# 0425, 2022-02-24 08:10:10, PP (100%)

product = list()
ip = input()

while ip != 'q':
    product.append(ip.split())
    ip = input()

buy = input().split()
price = 0.0

for e in buy:
    for i in range(len(product)):
        if e == product[i][0]:
            price += float(product[i][1])

print('total payment', price)


# 0426, 2022-02-24 08:05:19, PP (100%)

m = input()
name = []
price = []
while m != 'q':
    n,p = m.split()
    name.append(n)
    price.append(float(p))
    m = input()
buy = input().split()
pay = 0
for e in buy:
    if e in name:
        pay += price[name.index(e)]
print('total payment ',pay)
        


# 0427, 2022-02-24 08:16:53, PP (100%)

n = input().split()
listt = []
lara = []
p = 0
while n[0] != 'q':
    listt.append(n[0])
    lara.append(n[1])
    n = input().split()
x = input().split()

for e in range(len(x)):
    if x[e] in listt:
        j = listt.index(x[e])
        p+=float(lara[j])    
print('total payment',p)


# 0428, 2022-02-24 08:10:31, PP (100%)

a = input()
x = []
while a != 'q':
    x += a.split()
    a = input()

    
t = input().split()
prize = 0
for i in range(len(x)-1):
    for j in range(len(t)):
        if t[j] == x[i]:
            prize += float(x[i+1])

print('total payment',str(prize))

# 0429, 2022-02-24 08:14:02, PP (100%)

a = input()
b = []
while a != 'q':
  name,price = a.split()
  price = float(price)
  b.append([name,price])
  a = input()

aa = input().split()
ans = 0
for i in aa:
    for j in b:
        if j[0] == i:
            ans += j[1]
print('total payment', ans)

# 0430, 2022-02-24 08:15:15, PP (100%)

k=input().split()
pro=[]
cash=[]
payment=0
while k[0]!='q':
    if k[0]!='q':
        pro.append(k[0])
        cash.append(k[1])
        k=input().split()
j=input().split()
for i in j:
    if i in pro:
        e=pro.index(i)
        payment+=float(cash[e])
print('total payment',payment)

# 0431, 2022-02-24 08:14:45, PP (100%)

a = input().split()
a[1] = float(a[1])
stock = []
all = 0
while a != ['q']:
    stock.append(a[0])
    a[1] = float(a[1])
    stock.append(a[1])
    a = input().split()
buy = input().split()
for i in range(len(buy)):
    x = stock.index(buy[i])
    money = stock[x+1]
    all += money
print('total payment',all)

# 0432, 2022-02-24 08:13:58, PP (100%)

ls = []
while True:
    inp = input()
    #print(inp)
    if inp == 'q':
        break
    name, price = inp.split(' ')
        
    price = float(price)
    
    ls.append((name, price))

inp = input('').split(' ')
total_price = 0
for item in inp:
    for i in range(len(ls)):
        if item == ls[i][0]:
            total_price += ls[i][1]

print('total payment', total_price)

# 0433, 2022-02-24 08:12:32, PP (100%)

stuff = input()
goods = []
price = []
while stuff != "q" :
    stuff = stuff.split()
    goods.append(stuff[0])
    price.append(stuff[1])
    stuff = input()

price = list(map(float,price)) 

total = 0
order = input().split()
for i in range(len(order)) :
    if order[i] in goods :
        total += price[goods.index(order[i])]


print("total payment", total)


# 0434, 2022-02-24 08:07:20, PP (100%)

b = input().split()
s = []
p = []
m = []
while b[0] != 'q':
    s.append(b[0])
    p.append(b[1])
    b = input().split()
d = input().split()
for e in range(len(p)):
    p[e] = float(p[e])
for e in d:
    if e in s:
        m.append(p[s.index(e)])
print('total payment',sum(m))

# 0435, 2022-02-24 08:09:16, PP (100%)

pro = []
price = []
x = input()
while x != 'q' :
    x = x.split(" ")
    pro.append(x[0])
    price.append(x[1])
    x = input()
n = input().split()
sum = 0
for e in n:
    i = pro.index(e)
    sum += float(price[i])
print("total payment", sum)

# 0436, 2022-02-24 08:10:21, PP (100%)

good = []
price = []
float_price = []
totle_price = 0
while True:
    a = input()
    if a == 'q': break
    else:
        c,d= a.split()
        good.append(str(c))
        price.append(float(d))
bill = input().split()
for i in bill:
    if i in good:
        j = good.index(i)
        totle_price += float(price[j])
print('total payment '+str(totle_price))
    

# 0437, 2022-02-24 08:07:14, PP (100%)

a = ''
lstname = []
lstprice = []

while a != 'q':
    a = input().strip()
    if a == 'q':
        break
    name, price = a.split()
    lstname.append(name)
    lstprice.append(float(price))
    
buy = input().split()
s = 0
for i in buy:
    s += lstprice[lstname.index(i)]
    
print('total payment ' + str(s))

# 0438, 2022-02-24 08:16:06, PP (100%)

d = []

x = input()
while(x != "q"):
    good,price = x.split()
    d.append([good,float(price)])
    x = input()
total = 0
b = input().split()


for x in b:
    for i in range(len(d)):
        if(d[i][0] == x):
            total = total + d[i][1]
            break

print("total payment ",end='')

print(total)


# 0439, 2022-02-24 08:14:43, PP (100%)

w=input()
a=[]
b=[]
while w != "q":
    w=w.split()
    a += [w[0]]
    b += [w[1]]
    w=input()
c=input().split()
cost=0
for e in c:
    if e in a:
        cost += float(b[a.index(e)])
print("total payment",cost) 

# 0440, 2022-02-24 08:09:50, PP (100%)

x = input()
name = []
price = []
sum = 0
while x != 'q':
    n = x.split()
    name.append(n[0])
    price.append(float(n[1]))
    x = input()

find = input().split()
for i in range(len(find)):
        sum += price[name.index(find[i])]
print('total payment',sum)


# 0441, 2022-02-24 08:05:11, PP (100%)

price = []
product = []
a = input()
while a != 'q':
  b,c = a.split()
  product.append(b)
  price.append(c)
  a = input()
n = input().split()
sum = 0
for c in n:
  if c in product:
    i = product.index(c)
    sum = sum+float(price[i])
print('total payment ',end='')
print(float(sum))

# 0442, 2022-02-24 08:07:55, PP (100%)

good = input()
goods_list = []
val_list = []
while good != 'q' :
    goods,val = good.split()
    goods_list.append(goods)
    val_list.append(float(val))
    good = input()

sell = input().split()
sum = 0
for e in sell :
    if e in goods_list :
        sum += val_list[goods_list.index(e)]

print('total payment '+str(sum))


# 0443, 2022-02-24 08:11:28, PP (100%)

good = []
price = []
fin_price = []
x =[]
while True :
    y = input()
    if y == 'q' :
        break
    else :
        x = y.split(' ')
        good.append(x[0])
        price.append(x[1])

for i in range(len(price)) :
    fin_price.append(float(price[i]))

total = 0.0

buy = input().split()

for i in (buy) :
    for e in range(len(good)) :
        if i == good[e] :
            total += fin_price[e]
            

print('total payment'+' '+str(total))

# 0444, 2022-02-24 08:13:23, PP (100%)

a=input().split()
data = []
while a[0] != 'q':
    data.append([a[0],a[1]])
    a = input().split()
ch = input().split()
total = 0
for i in ch:
    for k in data:
        if i == k[0]:
            total += float(k[1])
print('total payment'+' '+str(total))


# 0445, 2022-02-24 08:07:38, PP (100%)

pro = []
summ = 0
for i in range(100000):
    x = input()
    if x =='q':
        break
    else :
        sub = x.split()
        pro.append(sub[0])
        pro.append(float(sub[1]))
y = input().split()
for i in range(len(y)):
    pos = pro.index(y[i])
    summ = summ + float(pro[pos+1])

print('total payment' , summ)        
    


# 0446, 2022-02-24 08:08:57, PP (100%)

a= input().split()
x=[]
su=0
while a!=['q']:
    x+=[a]
    a= input().split()
a= input().split()
for i in a:
    for j in range(len(x)):
        if i==x[j][0]:
            su+=float(x[j][1])
print('total payment',su)


# 0447, 2022-02-24 08:15:53, PP (100%)

c = input()
product = []
price = []
while c != "q":
    product_e,price_e = c.split()
    product.append(product_e)
    price.append(price_e)
    c = input()
want = input().split()
i = 0
total_p =0
while i < len(want):
    if want[i] in product:
        k = 0
        while k<len(product):
            if want[i]==product[k]:
                total_p+=float(price[k])
            k+=1
    i+=1
print("total payment" +" "+ str(total_p))


# 0448, 2022-02-24 08:10:55, PP (100%)

goods = []
price = []
while True :
        x = input()
        if x == 'q' : break
        g,p = x.split()
        goods.append(g)
        price.append(p)
data = input().split()
sum_p = []
for e in data :
    for i in range(len(goods)) :
        if e == goods[i] :
            sum_p.append(price[i])
for i in range(len(sum_p)) :
    sum_p[i] = float(sum_p[i])

print('total payment',sum(sum_p))

# 0449, 2022-02-24 08:04:51, PP (100%)

name=list()
price=list()
pay=0
while True:
  x=input()
  if x=='q':
    break
  a,b=x.split()
  name.append(a)
  price.append(b)
buy=[i for i in input().split()]
for j in buy:
  pay+=float(price[name.index(j)])
print('total payment',pay)

# 0450, 2022-02-24 08:10:27, PP (100%)

name = []
cost = []
money = 0

while True:
  inp = input()
  if inp == 'q':
    break
  inp = inp.split()
  name.append(inp[0])
  cost.append(float(inp[1]))
  
buy = input().split()
for i in buy:
  index = name.index(i)
  money += cost[index]
  
print('total payment',money)


# 0451, 2022-02-24 08:11:10, PP (100%)

in1 = []

while True:
	inp = input()

	if inp == 'q':
		break

	else:
		in1.append(inp.split())


in2 = input().split()

tot = 0

for i in in2:
	for j in in1:

		if i == j[0]:
			tot += float(j[1])

		else:
			pass
print("total payment {}".format(tot))


# 0452, 2022-02-24 08:07:15, PP (100%)

#grader quiz week 6
catalog = []
payment = 0
goods_key = []
while 1:
    goods = input()
    if goods == 'q':
        break
    goods = goods.strip().split()
    goods[1] = float(goods[1])
    catalog.append(goods)
for item in catalog:
    goods_key.append(item[0])
purchase = input().split()
for e in purchase:
    if e in goods_key:
        index = goods_key.index(e)
        payment += catalog[index][1]
print("total payment {}".format(payment))

# 0453, 2022-02-24 08:05:50, PP (100%)

s = input().split()
name = []
p = []
while s[0]!='q' :
    name.append(s[0])
    p.append(s[1])
    s = input().split()
l = input().split()
n = 0
for ch in l :
    if ch in name :
        e = name.index(ch)
    n += float(p[e])
print('total payment',n)


# 0454, 2022-02-24 08:09:51, PP (100%)

list_name = []
list_price = []
while True:
    inp = input()
    if inp == "q":
        break
    list_name.append(inp.split(" ")[0])
    list_price.append(inp.split(" ")[1])
shopping = input()
list_shop = shopping.split(" ")
sum = 0
for name in list_shop:

    if name in list_name:
        sum+=float(list_price[list_name.index(name)])
print("total payment " + str(sum))

# 0455, 2022-02-24 08:10:55, PP (100%)

a = input()
c = []
while a != 'q':
    x,y = a.split()
    c.append([x,float(y)])
    a = input()
d = input().split()
total = 0
for e in range(len(c)):
    for i in range(len(d)):
        if d[i] in c[e]:
            total += c[e][1]
print('total payment', total)



# 0456, 2022-02-24 08:14:36, PP (100%)

k = []
for i in range(1000):

    x = input()
    if x != 'q':
        x = x.split()
        k.append(x)
    else:
        break
y = input().split()
c = 0
for i in y:
    for j in k:
        if i == j[0]:
            c += float(j[1])
print('total payment '+str(c))

# 0457, 2022-02-24 08:08:20, PP (100%)

x = input()
ids = []
price = []
total = 0
while x != "q" :
    y = x.split()
    ids.append(y[0])
    price.append(y[1])
    x = input()
order = input().split()
for e in order :
    if e in ids :
        price_loca = ids.index(e)
        total += float(price[price_loca])
        
print("total payment", str(total))


# 0458, 2022-02-24 08:11:53, PP (100%)

def find(s, L):
    for i in range(len(L)):
        if s == L[i][0]:
            return i
    return -1
    
GOODS = list()  
inp = input().strip()
while inp != 'q':
    inp = inp.split()
    GOODS.append([inp[0], float(inp[1])])
    inp = input().strip()

buys = input().strip().split()
price = 0
for b in buys:
    idx = find(b, GOODS)
    price += GOODS[idx][1]
print("total payment", price)

Max Score = 50


# 0459, 2022-02-24 08:04:51, xx (0%)

a = input().split()
sin = []
cost = []
k = 0
while a != 'q':
  x,y = a.split()
  sin.append(x)
  cost.append(y)
  a = input()
ans = input().split()
total = 0
while k < range(len(ans)):
  for i in range(len(x)):
    if ans[k] == x[i]:
      k += 1
      total += y[i]
print('total payment', total)
# 0460, 2022-02-24 08:05:59, xx (0%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(y)
  a = input()
ans = input().split()
total = 0
while k < range(len(ans)):
  for i in range(len(x)):
    if ans[k] == x[i]:
      k += 1
      total += y[i]
print('total payment', total)
# 0461, 2022-02-24 08:06:52, TT (0%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(y)
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    if ans[k] == x[i]:
      k += 1
      total += y[i]
print('total payment', total)
# 0462, 2022-02-24 08:08:11, xx (0%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(y)
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    if ans[k] == sin[i]:
      k += 1
      total += cost[i]
print('total payment', total)
# 0463, 2022-02-24 08:08:54, Tx (0%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(y)
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    if ans[k] == sin[i]:
      k += 1
      total += float(cost[i])
print('total payment', total)
# 0464, 2022-02-24 08:09:36, Tx (0%)

#23/2/2022 test
a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    if ans[k] == sin[i]:
      k += 1
      total += cost[i]
print('total payment', total)
# 0465, 2022-02-24 08:11:00, xx (0%)

#23/2/2022 test
a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)) and k < len(ans):
    if ans[k] == sin[i]:
      k += 1
      total += cost[i]
print('total payment', total)
# 0466, 2022-02-24 08:11:57, compilation error (0%)

#23/2/2022 test
a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x))
    while k < len(ans):
      if ans[k] == sin[i]:
        k += 1
        total += cost[i]
print('total payment', total)

# 0467, 2022-02-24 08:12:14, TT (0%)

#23/2/2022 test
a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    while k < len(ans):
      if ans[k] == sin[i]:
        k += 1
        total += cost[i]
print('total payment', total)
# 0468, 2022-02-24 08:12:32, TT (0%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(x)):
    while k < len(ans)-1:
      if ans[k] == sin[i]:
        k += 1
        total += cost[i]
print('total payment', total)
# 0469, 2022-02-24 08:13:27, Px (50%)

a = input()
sin = []
cost = []
k = 0
while a != 'q':
  x, y = a.split()
  sin.append(x)
  cost.append(float(y))
  a = input()
ans = input().split()
total = 0
while k < len(ans):
  for i in range(len(sin)):
    if ans[k] == sin[i]:
      k += 1
      total += cost[i]
print('total payment', total)

# 0470, 2022-02-24 08:15:44, P- (50%)

m = input().split()
ids = [m[0]]
price = [m[1]]
while not 'q' in ids:
    y = input().split()
    if y[0] == 'q':
        break
    else:
        ids.append(y[0])
        price.append(y[1])
want = input().split()
sum_price = []
for e in ids:
    if e in want:
        i = ids.index(e)
        sum_price.append(float(price[i]))
for i in range(1,len(want)):
    if want[i] == want[i-1]:
        sum_price.append(float(price[1]))
sumprice = sum(sum_price)
print('total payment', sumprice)

# 0471, 2022-02-24 08:09:55, P- (50%)

a = input()
r = []
t = 0
for i in a :
    if a != "q" :
        k = a.split()
        r.append([k[0],k[1]])
        a = input()
    else : break
a = input().split()
b = []
for i in range(len(r)) :
    if r[i][0] in a :
        b.append(r[i][1])
for i in range(len(b)) :
    b[i] = float(b[i])
    t += b[i]

print("total payment " + str(t))

# 0472, 2022-02-24 08:10:42, P- (50%)

data = []
ip = input()
while ip != "q" :
  data.append(ip.split())
  ip = input()

x = input().split()

price = []
for e in data :
  if e[0] in x :
    price.append(float(e[1]))

print("total payment " + str(sum(price)))

Max Score = 0


# 0473, 2022-02-24 08:12:02, compilation error (0%)

products = []
while True:
i = input()
if i != 'q':
products += [i]
else:
break

order = input().split()
total = 0
for i in order:
for j in products:
if i == j.split()[0]:
total+=float(j.split()[1])
print('total payment',total)
# 0474, 2022-02-24 08:12:35, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
for j in products:
if i == j.split()[0]:
total+=float(j.split()[1])
print('total payment',total)
# 0475, 2022-02-24 08:13:13, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
for j in products:
if i == j.split()[0]:
total+=float(j.split()[1])
print('total payment'+ str(total))
# 0476, 2022-02-24 08:13:32, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
for j in products:
if i == j.split()[0]:
total+=float(j.split()[1])
print('total payment'+ total)
# 0477, 2022-02-24 08:13:49, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
  for j in products:
    if i == j.split()[0]:
      total+=float(j.split()[1])
print('total payment'+ total)
# 0478, 2022-02-24 08:14:14, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
  for j in products:
    if i == j.split()[0]:
      total+=float(j.split()[1])
print('total payment '+ total)
# 0479, 2022-02-24 08:14:37, compilation error (0%)

products = []
while True:
  i = input()
if i != 'q':
  products += [i]
else:
  break

order = input().split()
total = 0
for i in order:
  for j in products:
    if i == j.split()[0]:
      total+=float(j.split()[1])
print('total payment ' + str(total))
# 0480, 2022-02-24 08:15:22, compilation error (0%)

a = []
while True:
    i = input()
    if i != 'q':
        a +=  [i]
    else:
        break
    
b = input().split()
c = 0
for i in b:
    for j in a:
        if i == j.split()[0]:
            c+=float(j.split()[1])

print(f'total payment {c}')

# 0481, 2022-02-24 08:08:30, xx (0%)

x = input().split()
a = []
while x != q :
    a.apend(x)
    x = input().split()

#a = [a 100 ... ]
s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s = append.a[i]
# s = [123]
for i in range (len(s)) :
    t = t + int(s[i])

print ("total payment" + " " + str(t))
# 0482, 2022-02-24 08:09:26, xx (0%)

x = input().split()
a = []
while x != q :
    a.apend(x)
    x = input().split()

#a = [a 100 ... ]
s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s.append(a[i])
# s = [123]
for i in range (len(s)) :
    t = t + int(s[i])

print ("total payment" + " " + str(t))
# 0483, 2022-02-24 08:10:22, xx (0%)

x = input().split()
a = []
while x != q :
    a.apend(x)
    x = input().split()


s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s.append(a[i])

for i in range (len(s)) :
    t = t + int(s[i])

print ("total payment" + " " + str(t))
# 0484, 2022-02-24 08:10:44, xx (0%)

x = input().split()
a = []
while x != q :
    a.apend(x)
    x = input().split()


s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s.append(a[i])

t = 0 
for i in range (len(s)) :
    t = t + int(s[i])

print ("total payment" + " " + str(t))
# 0485, 2022-02-24 08:11:08, xx (0%)

x = input().split()
a = []
while x != q :
    a.apend(x)
    x = input().split()


s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s.append(a[i])

t = 0 
for i in range (len(s)) :
    t = t + float(s[i])

print ("total payment" + " " + str(t))
# 0486, 2022-02-24 08:12:07, xx (0%)

x = input().split()
a = []
while x != "q" :
    a.apend(x)
    x = input().split()

#a = [a 100 ... ]
s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s = append.a[i]
# s = [123]
for i in range (len(s)) :
    t = t + float(s[i])

print ("total payment" + " " + str(t))

# 0487, 2022-02-24 08:12:54, xx (0%)

x = input().split()
a = []
while x != "q" :
    a.append(x)
    x = input().split()

#a = [a 100 ... ]
s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s = append.a[i]
# s = [123]
for i in range (len(s)) :
    t = t + float(s[i])

print ("total payment" + " " + str(t))
# 0488, 2022-02-24 08:15:04, xx (0%)

x = input()
a = []
b = []
while x != "q" :
    x = x.split()
    a.append(x)
    
    x = input().split()
  

#a = [a 100 ... ]
s = []
for i in range (len(a)) :
    if i % 2 != 0 :
        s = append.a[i]
# s = [123]
for i in range (len(s)) :
    t = t + float(s[i])

print ("total payment" + " " + str(t))

# 0489, 2022-02-24 08:12:25, xx (0%)

a = input().split
cost = []
name = []
while a[0] != q:
    cost += float[a[1]]
    name += x[0]
    a = input.split()
b = input().split
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
    
    
    



# 0490, 2022-02-24 08:12:49, xx (0%)

a = input().split
cost = []
name = []
while a[0] != q:
    cost += [float[a[1]]]
    name += [x[0]]
    a = input.split()
b = input().split
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
# 0491, 2022-02-24 08:13:56, compilation error (0%)

a = input().split
cost = []
name = []
while a[0] != 'q":
    cost += [float[a[1]]]
    name += [x[0]]
    a = input.split()
b = input().split
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
# 0492, 2022-02-24 08:14:08, compilation error (0%)

a = input().split
cost = []
name = []
while a[0] != 'q":
    cost += float[a[1]]
    name += x[0]
    a = input.split()
b = input().split
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
# 0493, 2022-02-24 08:15:01, compilation error (0%)

a = input().split
cost = []
name = []
while a[0] != 'q":
    cost.append(float(a[1]))
    name.append(a[0])
    a = input.split()
b = input().split
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
# 0494, 2022-02-24 08:15:22, compilation error (0%)

a = input().split()
cost = []
name = []
while a[0] != 'q":
    cost.append(float(a[1]))
    name.append(a[0])
    a = input.split()
b = input().split()
c = 0
for i in b:
    c += [name.index(a)]
print('total payment',c)
# 0495, 2022-02-24 08:15:57, compilation error (0%)

a = input().split()
cost = []
name = []
while a[0] != 'q":
    cost.append(float(a[1]))
    name.append(a[0])
    a = input.split()
b = input().split()
c = 0
for a in b:
    c += [name.index(a)]
print('total payment',c)

# 0496, 2022-02-24 08:06:12, compilation error (0%)

x = input.()
name=[]
price=[]
while x!=q :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(name)):
    if name[i] in order :
        t+=price[i]
        
print ('totat payment'+' '+t)
# 0497, 2022-02-24 08:06:40, xx (0%)

x = input()
name=[]
price=[]
while x!=q :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(name)):
    if name[i] in order :
        t+=price[i]
        
print ('totat payment'+' '+t)
# 0498, 2022-02-24 08:07:18, xx (0%)

x = input()
name=[]
price=[]
while x!='q' :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(name)):
    if name[i] in order :
        t+=price[i]
        
print ('totat payment'+' '+t)
# 0499, 2022-02-24 08:09:51, -- (0%)

x = input()
name=[]
price=[]
while x!='q' :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(name)):
    if name[i] in order :
        t+=price[i]
        
print ('totat payment'+' '+str(t))
# 0500, 2022-02-24 08:14:50, xx (0%)

x = input()
name=[]
price=[]
while x!='q' :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(order)):
    if order[i] in name :
        t+=price[name.index(order)]
        
print ('totat payment'+' '+str(t))
# 0501, 2022-02-24 08:16:04, -- (0%)

x = input()
name=[]
price=[]
while x!='q' :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(order)):
    if order[i] in name :
        t+=price[name.index(order[i])]
        
print ('totat payment'+' '+str(t))
# 0502, 2022-02-24 08:16:24, -- (0%)

x = input()
name=[]
price=[]
while x!='q' :
    n,p=x.split()
    name.append(n)
    price.append(float(p))
    x=input()
t=0
order = input().split()
for i in range(len(order)):
    if order[i] in name :
        t+=price[name.index(order[i])]
        
print ('totat payment'+' '+str(t))

# 0503, 2022-02-24 08:09:46, xx (0%)

x = (input().split())
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[:2] == y[i]:
            total.append(x[2:2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
    print("total payment"+str(output))       
# 0504, 2022-02-24 08:12:58, xx (0%)

x = input().split()
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[1::2] == y[i]:
            total.append(x[2::2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
    print("total payment"+str(output))
# 0505, 2022-02-24 08:13:50, compilation error (0%)

x = input().split()
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[1::2] == y[i]:
            total.append(x[2::2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
    print("total payment"+,output)
# 0506, 2022-02-24 08:14:06, xx (0%)

x = input().split()
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[1::2] == y[i]:
            total.append(x[2::2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
    print("total payment",output)
# 0507, 2022-02-24 08:14:47, xx (0%)

x = input().split()
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[1::2] == y[i+1]:
            total.append(x[2::2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
    print("total payment",output)
# 0508, 2022-02-24 08:15:15, xx (0%)

x = input().split()
total = []
output = 0
if x != q:
    y = input().split()
    for i in len(y):
        if x[1::2] == y[i+1]:
            total.append(x[2::2])
        totally = total.split()
        for i in len(totally):
            output+= int(totally[i])
print("total payment",output)

# 0509, 2022-02-24 08:08:38, xx (0%)

while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input().split
k=0
total=0
while True:
    if x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))
# 0510, 2022-02-24 08:09:30, xx (0%)

name=[]
price=[]
while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input().split
k=0
total=0
while True:
    if x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))
# 0511, 2022-02-24 08:11:13, TT (0%)

name=[]
price=[]
while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input()
x=x.split()
k=0
total=0
while True:
    if x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))


# 0512, 2022-02-24 08:12:38, TT (0%)

name=[]
price=[]
while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input().split()
k=0
total=0
while True:
    if x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))


# 0513, 2022-02-24 08:14:19, compilation error (0%)

name=[]
price=[]
while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input().split()
k=0
total=0
while x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))
# 0514, 2022-02-24 08:14:38, TT (0%)

name=[]
price=[]
while True:
    s=input()
    if s=='q':break
    a,b=s.split()
    name.append(a)
    price.append(b)
x=input().split()
k=0
total=0
while True:
    if x[k] in a:
        j=a.index(x[k])
        total+=b[j]
        k+=1
    if k==len(x):break
print('total payment'+str(total))

# 0515, 2022-02-24 08:14:10, compilation error (0%)

a = []
while True:
i = input()
if i != 'q':
a.append(i)
else:
break
b = input().split()
c= []
for i in b:
for j in a:
if i == j.split()[0]:
c+=[float(j.split()[1])]

print(f'total payment {sum(c)}')

# 0516, 2022-02-24 08:14:21, compilation error (0%)

a = []
while True:
i = input()
if i != 'q':
a.append(i)
else:
break
b = input().split()
c= []
for i in b:
for j in a:
if i == j.split()[0]:
c+=[float(j.split()[1])]
print(f'total payment {sum(c)}')
# 0517, 2022-02-24 08:15:19, compilation error (0%)

a = []
while True:
  i = input()
  if i != 'q':
  a.append(i)
else:
  break
  b = input().split()
  c= []
  for i in b:
  for j in a:
  if i == j.split()[0]:
  c+=[float(j.split()[1])]

print(f'total payment {sum(c)}')
# 0518, 2022-02-24 08:15:47, compilation error (0%)

a = []
while True:
  i = input()
  if i != 'q':
  a.append(i)
else:
  break
  b = input().split()
  c= []
  for i in b:
  for j in a:
  if i == j.split()[0]:
  c+=[float(j.split()[1])]

print(f'total payment {sum(c)}')
# 0519, 2022-02-24 08:16:10, compilation error (0%)

a = []
while True:
  i = input()
  if i != 'q':
  a.append(i)
else:
  break
  b = input().split()
  c= []
  for i in b:
  for j in a:
  if i == j.split()[0]:
  c+=[float(j.split()[1])]

print(f'total payment {sum(c)}')

# 0520, 2022-02-24 08:07:48, xx (0%)

x=[e for e in input().split()]
y=input.split()
z=[]
for i in x:
    if x[i]!='q':
        z.append(x[i])
    else:
        break
print('total payment '+sum(z))
        
# 0521, 2022-02-24 08:08:32, xx (0%)

x=[e for e in input().split()]
y=input.split()
z=[]
for i in x:
    if x[1]!='q':
        z.append(x[1])
    else:
        break
print('total payment '+sum(z))
# 0522, 2022-02-24 08:11:22, xx (0%)

x=[e for e in input().split()]
y=input.split()
x.split(' ')
z=[]
for i in x:
    if x[1]!='q':
        z.append(x[1])
    else:
        break
print('total payment '+sum(z))
# 0523, 2022-02-24 08:12:13, xx (0%)

x=[e for e in input().split()]
y=input.split()
x=[x]
z=[]
for i in x:
    if x[1]!='q':
        z.append(x[1])
    else:
        break
print('total payment '+sum(z))
# 0524, 2022-02-24 08:14:52, xx (0%)

x=[e for e in input().split()]
y=input.split()
x=[x]
z=[]
for i in x:
  for i in len(e):
    if x[1]!='q':
        z.append(x[1])
    else:
        break
print('total payment '+sum(z))

# 0525, 2022-02-24 08:12:58, xx (0%)

code1 = input()
S = []
Price = []
while code1 != 0 :
  code1.split()
  S.append(code1[0])
  Price.append(code1[1])
  code1 = input()
Want = input().split()
Pay = 0
k = 0
while k <= len(S)-1 :
  if S[k] in Want :
    Pay = Pay + float(Price[k])
  else :
    pass
  k = k+1
Out = "total payment" + str(Pay)
print(Out)
# 0526, 2022-02-24 08:13:39, xx (0%)

code1 = input()
S = []
Price = []
while code1 != q :
  code1.split()
  S.append(code1[0])
  Price.append(code1[1])
  code1 = input()
Want = input().split()
Pay = 0
k = 0
while k <= len(S)-1 :
  if S[k] in Want :
    Pay = Pay + float(Price[k])
  else :
    pass
  k = k+1
Out = "total payment" + str(Pay)
print(Out)
# 0527, 2022-02-24 08:13:59, -- (0%)

code1 = input()
S = []
Price = []
while code1 != "q" :
  code1.split()
  S.append(code1[0])
  Price.append(code1[1])
  code1 = input()
Want = input().split()
Pay = 0
k = 0
while k <= len(S)-1 :
  if S[k] in Want :
    Pay = Pay + float(Price[k])
  else :
    pass
  k = k+1
Out = "total payment" + str(Pay)
print(Out)
# 0528, 2022-02-24 08:14:20, -- (0%)

code1 = input()
S = []
Price = []
while code1 != "q" :
  code1.split()
  S.append(code1[0])
  Price.append(code1[1])
  code1 = input()
Want = input().split()
Pay = 0
k = 0
while k <= len(S)-1 :
  if S[k] in Want :
    Pay = Pay + float(Price[k])
  else :
    pass
  k = k+1
Out = "total payment" + " "+ str(Pay)
print(Out)
# 0529, 2022-02-24 08:16:06, -- (0%)

code1 = input()
S = []
Price = []
while code1 != "q" :
  code1.split()
  S.append(code1[0])
  Price.append(code1[1])
  code1 = input()
Want = input().split()
Pay = 0
k = 0
while k <= len(S)-1 :
  if S[k] in Want :
    Pay = Pay + float(Price[k])
  else :
    pass
  k = k+1
Out = "total payment" + " "+ str(Pay)
print(Out)

# 0530, 2022-02-24 08:11:32, compilation error (0%)

s=[]
x=input()
while x!= 'q'
     s.append(x)
b=input().split()
sum=0
for i in range(len(b))     :
  for j in s[i][0]:
    if b[i] == j :
      sum+= s[i][1]
print('total payment',sum)
# 0531, 2022-02-24 08:11:55, TT (0%)

s=[]
x=input()
while x!= 'q':
     s.append(x)
b=input().split()
sum=0
for i in range(len(b))     :
  for j in s[i][0]:
    if b[i] == j :
      sum+= s[i][1]
print('total payment',sum)
# 0532, 2022-02-24 08:12:43, -x (0%)

s=[]
x=input()
while x!= 'q':
     s.append(x)
     x=input()
b=input().split()
sum=0
for i in range(len(b))     :
  for j in s[i][0]:
    if b[i] == j :
      sum+= s[i][1]
print('total payment',sum)
# 0533, 2022-02-24 08:14:21, xx (0%)

s=[]

while True:
     if x=="q":break
     else:
      s.append(x)
      x=input()
b=input().split()
sum=0
for i in range(len(b))     :
  for j in s[i][0]:
    if b[i] == j :
      sum+= s[i][1]
print('total payment',sum)
# 0534, 2022-02-24 08:15:33, xx (0%)

s=[]

while True:
     if x=="q":break
     else:
      s.append(x)
      x=input()
b=input().split()
sum=0
for i in range(len(b))     :
  for j in s[i][0]:
    if b[i] == j :
      sum+= s[i][1]
print('total payment',float(sum))

# 0535, 2022-02-24 08:10:05, -x (0%)

lst = []
price = []
sumPrice = []
ans = 0
z = input()
while z != 'q':
    x,y = z.split()
    y = float(y)
    lst.append(x)
    price.append(y)
    z = input()
choose = input().split()

for i in range(len(choose)):
    if choose[i] in lst:
        sumPrice.append(int(price[i]))
    
for c in sumPrice:
    ans += c
print(ans)
# 0536, 2022-02-24 08:14:01, -x (0%)

lst = []
price = []
sumPrice = []
ans = 0
z = input()
while z != 'q':
    x,y = z.split()
    y = float(y)
    lst.append(x)
    price.append(y)
    z = input()
choose = input().split()

for i in range(len(choose)-1):
    if choose[i] in lst:
        sumPrice.append(price[i])
    
for c in sumPrice:
    ans += c
print('totalpayment', ans)
    
# 0537, 2022-02-24 08:14:16, -x (0%)

lst = []
price = []
sumPrice = []
ans = 0
z = input()
while z != 'q':
    x,y = z.split()
    y = float(y)
    lst.append(x)
    price.append(y)
    z = input()
choose = input().split()

for i in range(0, len(choose)):
    if choose[i] in lst:
        sumPrice.append(price[i])
    
for c in sumPrice:
    ans += c
print('totalpayment', ans)
# 0538, 2022-02-24 08:15:12, -x (0%)

lst = []
price = []
sumPrice = []
ans = 0
z = input()
while z != 'q':
    x,y = z.split()
    y = float(y)
    lst.append(x)
    price.append(y)
    z = input()
choose = input().split()

for i in range(0, len(choose)):
    if choose[i] in lst:
        sumPrice.append(price[i])
    
for c in sumPrice:
    ans += c
print('totalpayment', ans)
# 0539, 2022-02-24 08:15:44, -x (0%)

lst = []
price = []
sumPrice = []
ans = 0
z = input()
while z != 'q':
    x,y = z.split()
    y = float(y)
    lst.append(x)
    price.append(y)
    z = input()
choose = input().split()

for i in range(len(choose)):
    if choose[i] in lst:
        sumPrice.append(price[i])
    
for c in sumPrice:
    ans += c
print('totalpayment', ans)

# 0540, 2022-02-24 08:12:53, xx (0%)

x=input().split()
c=[]
while x!='q':
    c+=[x]
    x=input().split()
y=input().split()
summ=0
for i in y:
    for j in c:
        if i==j:
            summ+=float(x[i+1])
print('total payment ',summ)
# 0541, 2022-02-24 08:15:19, xx (0%)

x=input().split()
c=[]
while x!='q':
    c+=[x]
    x=input().split()
y=input().split()
summ=0
for i in y:
    for j in c:
        if i==j:
            summ+=float(c[i+1])
print('total payment ',summ)
# 0542, 2022-02-24 08:15:33, xx (0%)

x=input().split()
c=[]
while x!='q':
    c+=[x]
    x=input().split()
y=input().split()
summ=0
for i in y:
    for j in c:
        if i==j:
            summ+=float(c[i+1])
print('total payment ',summ)
# 0543, 2022-02-24 08:16:09, xx (0%)

x=input().split()
c=[]
while x!='q':
    c+=x
    x=input().split()
y=input().split()
summ=0
for i in y:
    for j in c:
        if i==j:
            summ+=float(c[i+1])
print('total payment ',summ)

# 0544, 2022-02-24 08:10:28, x- (0%)

o = []
x = []
n = input()
o.append(n.split())
while n!= 'q':
    o.append(n.split())
    n = input()
m = input().split()
for i in range(len(o)):
    if m[i] == o[i]:
        x.append(float(o[i+1]))
print('total payment', sum(x))
# 0545, 2022-02-24 08:12:34, x- (0%)

o = []
x = []
n = input()
o.append(n.split())
while n!= 'q':
    o.append(n.split())
    n = input()
m = input().split()
for e in m:
    for i in range(len(o)):
        if m[i] == o[i]:
            x.append(float(o[i][1]))
print('total payment', sum(x))
# 0546, 2022-02-24 08:12:54, -- (0%)

o = []
x = []
n = input()
o.append(n.split())
while n!= 'q':
    o.append(n.split())
    n = input()
m = input().split()
for e in m:
    for i in range(len(o)):
        if m == o[i]:
            x.append(float(o[i][1]))
print('total payment', sum(x))
# 0547, 2022-02-24 08:14:41, -- (0%)

o = []
x = []
n = input()
o.append(n.split())
while n!= 'q':
    o.append(n.split())
    n = input()
m = input().split()
for e in m:
    for i in range(len(o)):
        if m == o[i][0]:
            x.append(float(o[i][1]))
print('total payment', sum(x))

# 0548, 2022-02-24 08:14:14, x- (0%)

pro =input()
li1 = []
li2 = []
while pro != "q":
    pro =input().split()
    li1.append(pro[0])
    li2.append(pro[1])
    pro =input()
print(li1)
s = input().split()
t=0
if s in li1:
    i = li.index(li1)
    t += float(li2[i])
print(t)
# 0549, 2022-02-24 08:14:56, -- (0%)

pro =input()
li1 = []
li2 = []
while pro != "q":
    pro =pro.split()
    li1.append(pro[0])
    li2.append(pro[1])
    pro =input()
print(li1)
s = input().split()
t=0
if s in li1:
    i = li.index(li1)
    t += float(li2[i])
print(t)
# 0550, 2022-02-24 08:15:17, x- (0%)

pro =input()
li1 = []
li2 = []
while pro != "q":
    pro =input().split()
    li1.append(pro[0])
    li2.append(pro[1])
    pro = input()
print(li1)
s = input().split()
t=0
if s in li1:
    i = li.index(li1)
    t += float(li2[i])
print(t)
# 0551, 2022-02-24 08:15:40, -- (0%)

pro =input()
li1 = []
li2 = []
while pro != "q":
    pro =pro.split()
    li1.append(pro[0])
    li2.append(pro[1])
    pro = input()

s = input().split()
t=0
if s in li1:
    i = li.index(li1)
    t += float(li2[i])
print(t)

# 0552, 2022-02-24 08:12:24, -- (0%)

input_list = []
while True:
    a = input()
    if a == 'q':
        break
    a = a.split()
    input_list.append(a)
b = input()
print (input_list)

total = 0
for i in b:
    for j in range(len(a)):
        if i == a[j][0]:
            total += a[j][1]
print('total payment', total)

# 0553, 2022-02-24 08:13:16, -- (0%)

input_list = []
while True:
    a = input()
    if a == 'q':
        break
    a = a.split()
    input_list.append(a)
b = input()
b = b.split()
print (input_list)

total = 0
for i in b:
    for j in range(len(a)):
        if i == a[j][0]:
            total += a[j][1]
print('total payment', total)

# 0554, 2022-02-24 08:14:38, xx (0%)

input_list = []
while True:
    a = input()
    if a == 'q':
        break
    a = a.split()
    input_list.append(a)
b = input()
b = b.split()
print (input_list)

total = 0
for i in range(len(b)):
    for j in range(len(a)):
        if a[i] == a[j][0]:
            total += a[j][1]
print('total payment', total)

# 0555, 2022-02-24 08:16:05, xx (0%)

input_list = []
while True:
    a = input()
    if a == 'q':
        break
    a = a.split()
    input_list.append(a)
b = input().split()

total = 0
for i in range(len(b)):
    for j in range(len(a)):
        if a[i] == a[j][0]:
            total += a[j][1]
print('total payment', total)


# 0556, 2022-02-24 08:12:34, -- (0%)

l1 = {}
while True:
    n = input().split()
    print(n)
    if n == ['q']:
        break
    l1[n[0]] = float(n[1])
print(l1)
shopping = input().split()
sum = 0
for i in shopping:
    sum += l1[i]
print('total payment {}'.format(sum))
# 0557, 2022-02-24 08:12:56, -- (0%)

l1 = {}
while True:
    n = input().split()
    print(n)
    if n == ['q']:
        break
    l1[n[0]] = float(n[1])
print(l1)
shopping = input().split()
sum = 0
for i in shopping:
    sum += l1[i]
print('total payment {}'.format(sum))
# 0558, 2022-02-24 08:16:02, xx (0%)

b = []
a = ""
w = 0
while True:
    a = input().split()
    if a == "q":
        break
    a = input().split()()
    b.append(a)

c = input().split()
for j in range(len(c)):
    for i in range(len(b)):
        if c[j] == b[i][0]:
            w +=b[i][1]
print("total payment",w)
# 0559, 2022-02-24 08:16:45, -- (0%)

l1 = {}
while True:
    n = input().split()
    print(n)
    if n == ['q']:
        break
    l1[n[0]] = float(n[1])

shopping = input().split()
sum = 0
for i in shopping:
    sum += l1[i]
print('total payment {}'.format(sum))

# 0560, 2022-02-24 08:12:15, xx (0%)

a,b=input().split
price=[float(b)]
product=[a]
while True:
    a,b=input().split
    if a == 'q':
        item=input().split()    
    else:
        product.append(a) 
        price.append(float(b))

total_price=0
for e in item:
    if e in product:
        y=index(e)
        total_price += price[y]
        
print('total payment',total_price)
# 0561, 2022-02-24 08:13:45, xx (0%)

a,b=input().split()
price=[float(b)]
product=[a]
while True:
    a,b=input().split()
    if a == 'q':
        item=input().split()
        break    
    else:
        product.append(a) 
        price.append(float(b))

total_price=0
for e in item:
    if e in product:
        y=index(e)
        total_price += price[y]
        
print('total payment',total_price)
# 0562, 2022-02-24 08:15:33, xx (0%)

a,b=input().split()
price=[float(b)]
product=[a]
while True:
    y=input().split()
    
    if y[0] == 'q':
        item=input().split()
        break    
    else:
        product.append(a) 
        price.append(float(b))

total_price=0
for e in item:
    if e in product:
        y=index(e)
        total_price += price[y]
        
print('total payment',total_price)
        
# 0563, 2022-02-24 08:16:40, -- (0%)

a,b=input().split()
price=[float(b)]
product=[a]
while True:
    y=input().split()
    
    if y[0] == 'q':
        item=input().split()
        break    
    else:
        product.append(a) 
        price.append(float(b))

total_price=0
for e in item:
    if e in product:
        y=product.index(e)
        total_price += price[y]
        
print('total payment',total_price)
        

# 0564, 2022-02-24 08:09:43, xx (0%)

x = input()
price = []
name = []
while x != 'q' :
  n,p = x.split()
  name.append(n)
  price.append(p)
  x = input()
pay = []
y = input().split()
for i in y:
  if i in name :
    f = name.index(i)
    pay.append(price(f))
print(sum(pay))

# 0565, 2022-02-24 08:14:17, -- (0%)

x = input()
price = []
name = []
while x != 'q' :
  n,p = x.split()
  name.append(n)
  price.append(float(p))
  x = input()
pay = []
y = input().split()
for i in y:
  if i in name :
    f = name.index(i)
    pay.append(price[f])
print(sum(pay))

# 0566, 2022-02-24 08:15:02, -- (0%)

x = input()
price = []
name = []
while x != 'q' :
  n,p = x.split()
  name.append(n)
  price.append(float(p))
  x = input()
pay = []
y = input().split()
for i in y:
  if i in name :
    f = name.index(i)
    pay.append(price[f])
print(sum(pay))

# 0567, 2022-02-24 08:15:34, -- (0%)

x = input()
price = []
name = []
while x != 'q' :
  n,p = x.split()
  name.append(n)
  price.append(float(p))
  x = input()
pay = []
y = input().split()
for i in y:
  if i in name :
    f = name.index(i)
    pay.append(price[f])
print(sum(pay))


# 0568, 2022-02-24 08:13:11, xx (0%)

product=[]
price=[]
x=input().split()

while x[0]!="q":
    
    product.append(x[0])
    price.append(float(x[1]))
    x=input().split()
news=input().split()
pri=0
for i in range(len(news)):
    pri+=price[product.index(news)]
print("total payment",pri)
    
# 0569, 2022-02-24 08:15:50, xx (0%)

product=[]
price=[]
x=input().split()

while x[0]!="q":
    
    product.append(x[0])
    price.append(float(x[1]))
    x=input().split()
news=input().split()
pri=0
for i in range(len(news)):
    pri+=price[product.index(news)]
print("total payment",pri)
# 0570, 2022-02-24 08:16:02, xx (0%)

product=[]
price=[]
x=input().split()

while x[0]!="q":
    
    product.append(x[0])
    price.append(float(x[1]))
    x=input().split()
news=input().split()
pri=0
for i in range(len(news)):
    pri+=price[product.index(news)]
print("total payment",pri)

# 0571, 2022-02-24 08:10:36, -- (0%)

list_pro = []
list_price = []
allpri = 0
x = input()
while x != "q":
    for e in x:
        z,y = x.split()
        list_pro.append(z)
        list_price.append(y)
        #["",""]
    x = input()
product = input().split()
for i in range(len(product)):
    if product[i] in list_pro:
        allpri += float(list_price[i])
print("total payment",allpri)
# 0572, 2022-02-24 08:13:39, -- (0%)

list_pro = []
list_price = []
allpri = 0
x = input()
while x != "q":
    for e in x:
        z,y = x.split()
        list_pro.append(z)
        list_price.append(y)
        #["",""]
    x = input()
product = input().split()
for i in range(len(product)):
    if product[i] in list_pro:
        allpri +=float(list_price[i])
print("total payment",allpri)
# 0573, 2022-02-24 08:14:30, -- (0%)

list_pro = []
list_price = []
allpri = 0
x = input()
while x != "q":
    for e in x:
        z,y = x.split()
        list_pro.append(z)
        list_price.append(float(y))
        #["",""]
    x = input()
product = input().split()
for i in range(len(product)):
    if product[i] in list_pro:
        allpri +=float(list_price[i])
print("total payment",allpri)


# 0574, 2022-02-24 08:14:14, -- (0%)

data=[]
s=0
a=input().split()
while a !="q":
    data.append(a)
    a=input()
b=input().split()

for c in b:
    for k in a:
        if k[0]==c:
            s+=float(k[1])

print("total payment", s)
# 0575, 2022-02-24 08:15:23, xx (0%)

data=[]
s=0
a=input().split()

while a !="q":
    data.append(a)
    a=input().split()
b=input().split()

for c in b:
    for k in a:
        if k[0]==c:
            s+=float(k[1])

print("total payment", s)
# 0576, 2022-02-24 08:16:04, -- (0%)

data=[]
s=0
a=input().split()

while a !="q":
    data.append(a)
    a=input()
    if a !="q":
      a=a.split()
b=input().split()

for c in b:
    for k in a:
        if k[0]==c:
            s+=float(k[1])

print("total payment", s)

# 0577, 2022-02-24 08:11:53, xx (0%)

x = input()
info = []
while x != 'q':
    info.append(x)
    info = input()
    if x=='q':
        break


buy = input().split()
price = 0
for e in buy:
    for i in range(len(buy)):
        if e in info[i]:
            price += float(e[1])
print('total payment ' + str(price))

# 0578, 2022-02-24 08:14:45, -x (0%)

x = input()
y = []
name = []
price = []

while x!='q':
    y.append(x)
    x = input()
    if x=='q':
        break
for e in y:
    e = e.split()
    name.append(e[0])
    price.append(e[1])


buy = input().split()
sum = 0
for e in buy:
    for i in range(len(buy)):
        if e in name[i]:
            sum += float(price[i])
print('total payment ' + str(sum))
# 0579, 2022-02-24 08:16:21, -x (0%)

x = input()
y = []
name = []
price = []

while x!='q':
    y.append(x)
    x = input()
    if x=='q':
        break
for e in y:
    e = e.split()
    name.append(e[0])
    price.append(e[1])

buy = input().split()
sum = 0
for e in buy:
    for i in range(len(buy)):
        if e in name[i]:
            sum += float(price[i])
print('total payment ' + str(sum))

# 0580, 2022-02-24 08:09:53, xx (0%)

x = input().split()
total = 0
while x != "q" :
    x = input().split()
    p = x[::2]

for i in p :
    p = p.append(float(p[i]))
    total = sum(p[i])

print("total payment ", total )  
# 0581, 2022-02-24 08:14:32, xx (0%)

x = input().split()
total = 0
while x != "q" :
    x = input().split()
p = []
item = input().split()
for i in item :
    if i in x :
        j = item.index()
        p += x[j+1]
total += sum(p[i])
print("total payment ", total )  
# 0582, 2022-02-24 08:15:45, xx (0%)

x = input().split()
total = 0
while x != "q" :
    x = input().split()
p = []
item = input().split()
for i in item :
    if i in x :
        j = item.index()
        p += x[j+1]
total += sum(p[i])
print("total payment", total )

# 0583, 2022-02-24 08:10:24, xx (0%)

x = input().split()
z =[]
p = 0
while x!='q' :
    z += [x]
    x = input().split()
y = input().split()
for i in y :
    for m in range(len(z)) :
        if i == z[m][0] :
            p += z[m][1]
print('total payment',p)
# 0584, 2022-02-24 08:12:07, xx (0%)

x = input().split()
z =[]
p = 0
while x!='q' :
    z += [x]
    x = input().split()
    if x =="q" :
        break
y = input().split()
for i in y :
    for m in range(len(z)) :
        if i == z[m][0] :
            p += z[m][1]
print('total payment',p)
# 0585, 2022-02-24 08:13:55, xx (0%)

z =[]
p = 0
while x!='q' :
    z += [x]
    x = input().split()
    if x =="q" :
        break
y = input().split()
for i in y :
    for m in range(len(z)) :
        if i == z[m][0] :
            p += z[m][1]
print('total payment',p)

# 0586, 2022-02-24 08:15:19, -- (0%)

x = []
y = 0.0
s = input()
while s != "q":
    s = s.split()
    x.append([s])
    s = input()

b = input().split()
for i in range(len(b)):
    for n in range(len(x)):
        if b[i] == x[n][0]:
            y += float(x[n][1])
            
print('total payment ' + str(y))
# 0587, 2022-02-24 08:15:42, xx (0%)

x = []
y = 0.0
s = input().split()
while s != "q":
    x.append([s])
    s = input().split()

b = input().split()
for i in range(len(b)):
    for n in range(len(x)):
        if b[i] == x[n][0]:
            y += float(x[n][1])
            
print('total payment ' + str(y))
# 0588, 2022-02-24 08:16:17, xx (0%)

x = []
y = 0.0
s = input().split()
while s != "q":
    x.append([s])
    s = input().split()

b = input().split()
for i in range(len(b)):
    for n in range(len(x)):
        if b[i] == x[n][0]:
            y += float(x[n][1])
            
print('total payment ' + str(y))

# 0589, 2022-02-24 08:11:47, compilation error (0%)

x=input()
t=[]
p=[]
while x!="q":
    x=x.split()
    t.append(x[0])
    p.append(x[1])
    x=input()
c=input().split()
for i in range len(c):
    a=t.index(c[i])
    b=p.index(p[a])
# 0590, 2022-02-24 08:12:40, compilation error (0%)

x=input()
t=[]
p=[]
while x!="q":
    x=x.split()
    t.append(x[0])
    p.append(x[1])
    x=input()
c=input().split()
for i in range len(c):
    a=t.index(c[i])
    b=p.index(t[a])
    print("total payment"+b)
# 0591, 2022-02-24 08:13:07, compilation error (0%)

x=input()
t=[]
p=[]
while x!="q":
    x=x.split()
    t.append(x[0])
    p.append(x[1])
    x=input()
c=input().split()
for i in range len(c):
    a=t.index(c[i])
    b=p.index(t[a])
print("total payment"+b)

# 0592, 2022-02-24 08:13:40, xx (0%)

w = input().split()
wa = []
c = 0
while w != ['q'] :
    wa.append(w)
    w = input().split()
a = input().split()
for i in range(len(wa)):
    for i in range(len(a)):
        if a[i] in wa[i]:
            i = wa[i].index(a[i])
            c += int(wa[i][i+1])
print(c)
# 0593, 2022-02-24 08:14:11, -x (0%)

w = input().split()
wa = []
c = 0
while w != ['q'] :
    wa.append(w)
    w = input().split()
a = input().split()
for i in range(len(wa)):
    for i in range(len(a)):
        if a[i] in wa[i]:
            i = wa[i].index(a[i])
            c += float(wa[i][i+1])
print(c)
# 0594, 2022-02-24 08:15:10, x- (0%)

w = input().split()
wa = []
c = 0
while w != ['q'] :
    wa.append(w)
    w = input().split()
a = input().split()
for i in range(len(a)):
    for i in range(len(wa)):
        if a[i] in wa[i]:
            i = wa[i].index(a[i])
            c += float(wa[i][i+1])
print(c)

# 0595, 2022-02-24 08:09:18, xx (0%)

lst = []
    
x = input()
while x != q :
    lst.append(x)
    x = input()
y = input()

for i in y :
  if lst in y :
    print

# 0596, 2022-02-24 08:14:01, xx (0%)

lst = []
    
x = input()
while x != q :
    lst.append(x)
    x = input()
x = [int(i) for i in input().split()]
for i in x:
    lst.append(i)

for i in y :
  if lst in y :
    print ()
# 0597, 2022-02-24 08:15:07, xx (0%)

lst = []
ans = []
x = input()
while x != q :
    lst.append(x)
    x = input()

x = [int(i) for i in input().split()]
for i in x:
    lst.append(i)

for i in y :
  if lst in y :
    ans.append(y)

# 0598, 2022-02-24 08:05:51, xx (0%)

n = ""
n = 0
c = ""
total = 0
while n != 'q':
    n += input().split()
k = input().split()
for i in range(len(k)):
    c += n.index(k[i])
for i in range(len(c)):
    total += float(n[i+1])
    
print('total payment',total)
# 0599, 2022-02-24 08:13:36, -- (0%)

n = []
p = []
c = []
total = 0
while True:
    s = input()
    if s == 'q':
        break
    a,b = s.split()
    n.append(a)
    p.append(b)
k = input().split()
for i in range(len(k)):
    if i in n:
        w = n.index(i)
        c.append(w)
for e in c:
    total += float(p[e])
    
print('total payment',total)

# 0600, 2022-02-24 08:16:33, xx (0%)

n = []
p = []
c = []
total = 0
while True:
    s = input()
    if s == 'q':
        break
    a,b = s.split()
    n.append(a)
    p.append(b)
k = input().split()
for i in range(len(k)):
    if k[i] in n:
        w = n.index(i)
        c.append(w)
for e in c:
    total += float(p[e])
    
print('total payment',total)


# 0601, 2022-02-24 08:15:10, xx (0%)

snew = input()
s = snew
price = []
while s!= 'q' :
    nn,pp = input(),int(input())
    prince.append(pp)
su = sum(pp)
  
# 0602, 2022-02-24 08:15:22, xx (0%)

snew = input()
s = snew
price = []
while s!= 'q' :
    nn,pp = input(),int(input())
    prince.append(pp)
lal = len(allin)
nn,pp = [],[]
allin = allin[0,-1]
allin = allin.split()
for i in range(lal) :
    if i %2 != 0:
        pp.append(allin)
    else: continue
su = sum(pp)
    
# 0603, 2022-02-24 08:15:32, xx (0%)

snew = input()
s = snew
price = []
while s!= 'q' :
    nn,pp = input(),int(input())
    prince.append(pp)
lal = len(allin)
nn,pp = [],[]
allin = allin[0,-1]
allin = allin.split()
for i in range(lal) :
    if i %2 != 0:
        pp.append(allin)
    else: continue
su = sum(pp)

# 0604, 2022-02-24 08:15:20, -- (0%)

list_good = []
buying = []
payment = float(0)
while True:
  i = input()
  if i != 'q':
    list_good.append(i.split())
  else:
    x = input()
    buying.append(x.split())
    break
print(buying)
print(list_good)
for i in buying:
  for x in list_good:
    if i[0] == x[0]:
      payment += float(x[1])
    elif i[1] == x[0]:
      payment += float(x[1])
    elif i[2] == x[0]:
      payment += float(x[1])
print("total payment ", float(payment))
# 0605, 2022-02-24 08:16:06, -- (0%)

list_good = []
buying = []
payment = float(0)
while True:
  i = input()
  if i != 'q':
    list_good.append(i.split())
  else:
    x = input()
    buying.append(x.split())
    break
print(buying)
print(list_good)
for i in buying:
  for x in list_good:
    for a in range(len(buying)):
      if i[a] == x[0]:
        payment += float(x[1])
print("total payment ", float(payment))
# 0606, 2022-02-24 08:16:33, -- (0%)

list_good = []
buying = []
payment = float(0)
while True:
  i = input()
  if i != 'q':
    list_good.append(i.split())
  else:
    x = input()
    buying.append(x.split())
    break
for i in buying:
  for x in list_good:
    for a in range(len(buying)):
      if i[a] == x[0]:
        payment += float(x[1])
print("total payment ", float(payment))

# 0607, 2022-02-24 08:12:39, -- (0%)

price=[]
while True:
    x = input()
    if x == "q" : break
    x = x.split()
    price.append(x[1])
y=input().split()
for i in range (len(y)):
    if y[i] in price:
        a=price.index(y[i])
        b+=price[a]

print("total payment "+"b")
# 0608, 2022-02-24 08:13:01, -- (0%)

price=[]
b=0
while True:
    x = input()
    if x == "q" : break
    x = x.split()
    price.append(x[1])
y=input().split()
for i in range (len(y)):
    if y[i] in price:
        a=price.index(y[i])
        b+=price[a]

print("total payment "+"b")
# 0609, 2022-02-24 08:15:38, -- (0%)

price=[]
b=0
while True:
    x = input()
    if x == "q" : break
    x = x.split()
    price.append(x[1])
y=input().split()
for i in range (len(y)):
    if y in price:
        a=price.index(y[i])
        b+=price[a]

print("total payment ",float (b))

# 0610, 2022-02-24 08:15:04, -- (0%)

data= []
x = input()
while x != str('q'):
    data.append(x)
    x = input()
y = ['alcoholGel','100.5','mask','50.25','atk','75.5','maskA,50.0','maskB','67.125','alcoholSpray','35']
z = input().split()
for i in range (len(y)):
    if y[i] == z:
        print(y[i+1])
        break  
# 0611, 2022-02-24 08:15:16, -- (0%)

data= []
x = input()
while x != str('q'):
    data.append(x)
    x = input()
y = ['alcoholGel','100.5','mask','50.25','atk','75.5','maskA,50.0','maskB','67.125','alcoholSpray','35']
z = input().split()
for i in range (len(y)):
    if y[i] == z:
        print(y[i+1])
        break
# 0612, 2022-02-24 08:16:34, xx (0%)

name=[];pri=[];b=0
while b==0:
    a=input().split()
    if(a!="q"):
        name.append(a[0])
        pri.append(a[1])
    else:
        break
total=0.0
buy=input().split()
for i in range (len(buy)):
    if (buy[i] in name):
        n=name.index(buy[i])
        total+=float(pri[n])
print ("total payment",total)

# 0613, 2022-02-24 08:10:22, xx (0%)

j= []
k = input()
while k != "q":
    j.append(k)
    k=input()
c=0
k = ""
for i in range(len(j)) :
    if i%2 !=0 :
        c+=j[i]
    if i%2 == 0:
        k+=j[i]
print(k,c)        
# 0614, 2022-02-24 08:12:53, compilation error (0%)

j= []
k = input()
while k != "q":
    j.append(k)
    k=input()
c=0
k = ""
for i in range(len(j)) :
    if i%2 !=0 :
        c+=j[i]
   
print(total payment,c)   
# 0615, 2022-02-24 08:13:26, compilation error (0%)

j= []
k = input()
while k != "q":
    j.append(k)
    k=input()
c=0

for i in range(len(j)) :
    if i%2 !=0 :
        c+=j[i]
   
print(total payment,c)        

# 0616, 2022-02-24 08:09:19, xx (0%)

n = input().split()
A = []
B = []
A.append(n[0])
B.append(float(n[1]))
c = 0
while n != 'q' :
    n = input().split()
buy = input().split()
for i in range(len(buy)):
    if buy[i] in A:
        x = A.index(buy[i])
        c += B[x]
print('total payment', c)
# 0617, 2022-02-24 08:12:18, xx (0%)

n = input().split()
A = []
B = []
A.append(n[0])
B.append(float(n[1]))
c = 0
while n != 'q' :
    n = input().split()
    A.append(n[0])
    B.append(float(n[1]))
buy = input().split()
for i in range(len(buy)):
    if buy[i] in A:
        x = A.index(buy[i])
        c += B[x]
        
print('total payment', c)
# 0618, 2022-02-24 08:16:51, xx (0%)

n = input().split()
A = []
B = []
A.append(n[0])
B.append(float(n[1]))
c = 0
while n != 'q' :
    n = input().split()
    A.append(n[0])
    B.append(float(n[1]))
buy = input().split()
for i in range(len(buy)):
    if buy[i] in A:
        x = A.index(buy[i])
        c += B[x]
        
print('total payment', c)

# 0619, 2022-02-24 08:14:06, xx (0%)

data = []
x = input().split()
while x != q:
    data.append([x[1],x[0]])
    x = input().split()
data.sort()

a = input().split()
ch = []
for e in a:
    ch.append(e)

b = []
for e in data:
    if ch in e[1]:
        b.append(float(e[0]))

sum = 0
for i in range(lens(b)):
    sum += b[i]

print("total payment",sum)
        


# 0620, 2022-02-24 08:15:21, xx (0%)

data = []
x = input().split()
while x != "q":
    data.append([x[1],x[0]])
    x = input().split()
data.sort()

a = input().split()
ch = []
for e in a:
    ch.append(e)

b = []
for e in data:
    if ch in e[1]:
        b.append(float(e[0]))

sum = 0
for i in range(lens(b)):
    sum += b[i]

print("total payment",sum)

# 0621, 2022-02-24 08:14:53, xx (0%)

s = input()
goods = []
prices = []
k = 0
while s != 'q':
  x, y = a.split()
  goods.append(x)
  prices.append(float(y))
  s = input()
bought = input().split()
total = 0
while k < len(bought):
  for i in range(len(x)):
    if bought[k] == goods[i]:
      k += 1
      total += prices[i]
print('total payment', total)
# 0622, 2022-02-24 08:15:52, Tx (0%)

s = input()
goods = []
prices = []
k = 0
while s != 'q':
  x, y = s.split()
  goods.append(x)
  prices.append(float(y))
  s = input()
bought = input().split()
total = 0
while k < len(bought):
  for i in range(len(x)):
    if bought[k] == goods[i]:
      k += 1
      total += prices[i]
print('total payment', total)

# 0623, 2022-02-24 08:13:28, xx (0%)

pro = []
pri = []
value = 0
while True :
    pro = input()
    if pro == "q":
        break
    s = pro.split()
    pro.append(s[0])
    pri.append(int(s[1]))
sp = input().split()
for i in range (len(pro)):
    if pro[i] in sp :
        value += pri[i]
print("total payment",value)   
# 0624, 2022-02-24 08:16:02, xx (0%)

pro = []
pri = []
value = 0
while True :
    x = input()
    if pro == "q":
        break
    s = x.split()
    pro.append(s[0])
    pri.append(int(s[1]))
sp = input().split()
for i in range (len(pro)):
    if pro[i] in sp :
        value += pri[i]
print("total payment",value)

# 0625, 2022-02-24 08:14:42, xx (0%)

s = input()
s_list = []
p_list = []
while s != 'q':
    s_list.append(s.split()[0])
    p_list.append(s.split()[1])
    s = input()
buy = input().split()
price = [0]*len(buy)
for i in range(len(buy)):
    price[i] = p_list[s_list.index(buy[i])]
all_price = 0
for c in price:
    all_price += c
print('total payment '+all_price)
# 0626, 2022-02-24 08:15:38, xx (0%)

s = input()
s_list = []
p_list = []
while s != 'q':
    s_list.append(s.split()[0])
    p_list.append(s.split()[1])
    s = input()
buy = input().split()
price = [0]*len(buy)
for i in range(len(buy)):
    price[i] = p_list[s_list.index(buy[i])]
all_price = 0
for c in price:
    all_price += float(c)
print('total payment '+all_price)

# 0627, 2022-02-24 08:15:35, xx (0%)

intake = []
ALL = 0
a = 0
while a != "q":
  intake += input().split()
want = input().split()
for i in range(len(want)):
  for o in intake:
    if i == intake[o]:
      ALL += int(intake[o+1])
print(ALL)
# 0628, 2022-02-24 08:15:53, xx (0%)

intake = []
ALL = 0
a = 0
while a != "q":
  intake += input().split()
want = input().split()
for i in range(len(want)):
  for o in intake:
    if i == intake[o]:
      ALL += int(intake[o+1])
print("total payment"+" "+str(ALL))

# 0629, 2022-02-24 08:14:50, -- (0%)

d=[]
while True:
  x=input()
  if x=='q':
    a,b=x.split()
    d.append(a)
  else:
    break
e=input().split()
z=0
for i in range(len(e)):
  if e[i] in d:
    j=d.index(e[i])
    k=d[j]
    z+=k
print(z)
# 0630, 2022-02-24 08:15:38, -- (0%)

d=[]
while True:
  x=input()
  if x=='q':
    a,b=x.split()
    d.append(a)
  else:
    break
e=input().split()
z=0
for i in range(len(e)):
  if e[i] in d:
    j=d.index(e[i])
    k=d[j]
    z+=k
print('total payment',z)

# 0631, 2022-02-24 08:05:27, xx (0%)

x=input().split()
t=[]
total=0
while x!='q':
    t.append(x)
    x=input().split()
buy=input.split()
for e in buy:
    for name,price in t:
        if e in name:
            total+=price    
print('total payment', total)
# 0632, 2022-02-24 08:09:26, xx (0%)

name,price =input().split()
t=[]
s=[]
total=0
while name!='q':
    t.append(name)
    s.append(price)
    name,price =input().split()
buy=input.split()
for e in buy:
    if e in t:
        total+=s[t.index(e)]    
print('total payment', total)

# 0633, 2022-02-24 08:11:59, -- (0%)

d=[]
n=input()
while n != 'q':
    d.append(n)
    n=input()
# 0634, 2022-02-24 08:15:32, compilation error (0%)

d=[]
n=input()
while n != 'q':
    d.append(n)
    n=input()
for f in d:
    if f%2==1:
    total  +=n[f]
        

# 0635, 2022-02-24 08:15:28, xx (0%)

name = [] ; cost = []
x = input()
while True:
    if x != 'q':
        x = x.split()
        name+=[x[0]] ; cost.append+=[x[1]]
total = 0
y = input().split()
for i in y:
    j = name.index(i)
    total += cost[j]
print('total payment',total)
# 0636, 2022-02-24 08:16:15, xx (0%)

name = [] ; cost = []
x = input()
while True:
    if x != 'q':
        x = x.split()
        name+=[x[0]] ; cost.append+=[x[1]]
    else: break
total = 0
y = input().split()
for i in y:
    j = name.index(i)
    total += cost[j]
print('total payment',total)

# 0637, 2022-02-24 08:13:33, -- (0%)

pro = []
l = []
n = input()
sum = 0.0
while n!= "q":
    pro.append(n)
    n = input()
for e in pro:
    x = e.split()
    l.append(x)
print(l)
m = input().split()
for item,cost in l:
    if item in m:
        sum +=float(cost)
print("total payment", sum)
# 0638, 2022-02-24 08:15:42, x- (0%)

pro = []
l = []
n = input()
sum = 0.0
while n!= "q":
    pro.append(n)
    n = input()
for e in pro:
    x = e.split()
    l.append(x)
print(l)
m = input().split()
for i in range(len(pro)):
    if m[i] in pro[i][0]:
        sum +=float(pro[i][1])
print("total payment", sum)


# 0639, 2022-02-24 08:15:22, xx (0%)

data = [input()]
total = 0
while data[len(data)-1]!= 'q':
  data.append(input())
data2 = [g for g in input().split()]
data = ''.join(str(f) for f in data)
name,price = [e for e in data.split()]
for i in range(len(data2)):
  for j in range(len(name)):
    if data2[i] == name[j] :
      total += price[j]

print('total payment',tatal)
# 0640, 2022-02-24 08:15:32, xx (0%)

data = [input()]
total = 0
while data[len(data)-1]!= 'q':
  data.append(input())
data2 = [g for g in input().split()]
data = ''.join(str(f) for f in data)
name,price = [e for e in data.split()]
for i in range(len(data2)):
  for j in range(len(name)):
    if data2[i] == name[j] :
      total += price[j]

print('total payment',total)

# 0641, 2022-02-24 08:15:54, -- (0%)

r=input().split()
p=[]
p.append(r[1])
while 'q' not in r:
    r=input()
    if 'q' not in r:
        p.append(r[1])
if 'q' in p:
    p.remove('q')
f=[]
for i in p:
    f.append(float(i))
j=sum(f)
print('total payment',j)
  


# 0642, 2022-02-24 08:16:54, -- (0%)

r=input().split()
p=[]
p.append(r[1])
while 'q' not in r:
    r=input()
    if 'q' not in r:
        p.append(r[1])
if 'q' in p:
    p.remove('q')
f=[]
for i in p:
    i=float(i)
    f.append(i)
j=sum(f)
print('total payment',j)
  



# 0643, 2022-02-24 08:11:41, xx (0%)


lis = []
price = []
s = input()
while s != 'q':
    s = s.split()
    lis.append(s[0])
    price.append(s[1])
    s = input()
price_pay = input().split()
for i in range(len(price_pay)):
    x = lis.index(price_pay[i])
    y = price.index(price[x])
    sums = 0
    for j in range(len(price_pay)) :
      sums += int(y[j])
for i in range(len(lis)):
    print('total payment', price[i])
# 0644, 2022-02-24 08:16:49, xx (0%)

lis = []
price = []
s = input()
while s != 'q':
    s = s.split()
    lis.append(s[0])
    price.append(s[1])
    s = input()
price_pay = input().split()
for i in price:
    for k in lis:
        if i == k[0]:
            total += float(k[1])
print('total payment' + ' ' + str(total))

# 0645, 2022-02-24 08:12:34, -- (0%)

x = []
y=input().split()
while y[0] != 'q':
    x.append(y)
    y = input().split()
listt = input().split()
c=0
for i in range(len(listt)):
    if listt[i][0] in x:
        c+= float(listt[i][1])
    
    
    
    
    
    
print('total payment' + str(c))
# 0646, 2022-02-24 08:14:15, -x (0%)

x = []
y=input().split()
while y[0] != 'q':
    x.append(y)
    y = input().split()
listt = input().split()
c=0
for i in range(len(listt)):
    if listt[i][0] == x[i][0]:
        c+= float(listt[i][1])
    
    
    
    
    
    
print('total payment' + str(c))

# 0647, 2022-02-24 08:15:55, compilation error (0%)

x = input().split()
d = []
p = []
for e in x:
    d.append(e%2 == 0)
for a in x:
    p.append(e%2 != 0)

while e != 'q':
      d.append(e%2 == 0) or p.append(e%2 != 0)

y = input().split

for e in y:
    if e == d[0]:
       price += p[0]
    elif == d[1]:
       price += p[1]
    elif == d[2]:
       price += p[2]
    elif == d[3]:
       price += p[3]

print('total payment'+price)
# 0648, 2022-02-24 08:16:33, xx (0%)

x = input().split()
d = []
p = []
for e in x:
    d.append(e%2 == 0)
for a in x:
    p.append(e%2 != 0)

while e != 'q':
      d.append(e%2 == 0) or p.append(e%2 != 0)

y = input().split

for e in y:
    if e == d[0]:
       price += p[0]
    elif e == d[1]:
       price += p[1]
    elif e == d[2]:
       price += p[2]
    elif e == d[3]:
       price += p[3]

print('total payment'+price)

# 0649, 2022-02-24 08:14:16, -x (0%)

li=[]
e = input()
while e!= "q":
    li.append(e)
    e = input()
x = []
for q in li:
    x.append(q.split())
d = input().split()
total = 0
for i in range(len(d)):
    if d[i] in x[i][0] :
        total+=float(x[i][1])
print('total payment',total)
# 0650, 2022-02-24 08:14:37, -x (0%)

li=[]
e = input()
while e!= "q":
    li.append(e)
    e = input()
x = []
for q in li:
    x.append(q.split())
d = input().split()
total = 0
for i in range(len(d)):
    if d[i] == x[i][0] :
        total+=float(x[i][1])
print('total payment',total)

# 0651, 2022-02-24 08:14:28, xx (0%)

A = []
B = []
x = input()
total = 0
while x != q :
  A.append(x[0])
  B.append(x[1])
  x = input()
buy = input().split()
for i in buy :
   total += float(B[A.index(e)])

print ("total payment",str(total))
# 0652, 2022-02-24 08:15:35, xx (0%)

A = []
B = []
x = input()
total = 0
while x != q :
  x = x.split()
  A.append(x[0])
  B.append(x[1])
  x = input()
buy = input().split()
for i in buy :
   total += float(B[A.index(e)])

print ("total payment",str(total))


# 0653, 2022-02-24 08:11:32, xx (0%)

product=[]
price=[]
e=input()
while e != 'q':
  x,y=e.split()
  product.append(x)
  price.append(y)
  e=input()
s = input().split()
for i in s :
    if i in product :
        d= product.index(i)
        a=sum(price[d])
print ('tatal payment',a)
# 0654, 2022-02-24 08:14:32, -- (0%)

product=[]
price=[]
e=input()
while e != 'q':
  x,y=e.split()
  product.append(x)
  price.append(y)
  e=input()
a=0
s = input().split()
for i in s :
    if i in product :
        d= product.index(i)
        a+= float(price[d])
print ('tatal payment',a)

# 0655, 2022-02-24 08:07:36, xx (0%)

data = []
x = float(input())
while x != q:
    data.append(x)
    x = float(input())
inp = input()
t = inp.split()
prolist = []
for x in t:
    prolist.append( float(x) )
# 0656, 2022-02-24 08:15:14, xx (0%)

data = []
x = input()
while x != q:
    data.append(x.split)
    x = input()
inp = input()
t = inp.split()
prolist = []
for x in t:
    prolist.append(x)
total = 0
for i in x:
    for c in range(len(data)):
        if data[i][0] == i:
            total += float(data[i][1]) 
print('total payment',total)

# 0657, 2022-02-24 08:13:23, -- (0%)

x = input()
d = []
while x != "q" :
    d.append(x)
    x = input()
    print(x)
# 0658, 2022-02-24 08:15:24, -- (0%)

x = input()
d = []
while x != "q" :
    d.append(x)
    x = input()
print(d)
    

# 0659, 2022-02-24 08:15:03, TT (0%)

x = input()
c=0
p=0
while x != "q":
    n,p0 = x.split()
    x = input()
    if x == "q" : break
y = [str(e) for e in input().split()]

for i in range(len(y)):
    c=0
    while y[i]!=n[i+c]:
        if y[i]== n[i+c]:
            l.append(i)
            p+=p0[i+c]
            c+=1
        if y[i] ==  n[i+c]: break

print('total payment', p)
# 0660, 2022-02-24 08:16:42, xx (0%)

x = input()
c=0
p=0
while x != "q":
    x = input()
    n,p0 = x.split()
    if x == "q" : break
y = [str(e) for e in input().split()]

for i in range(len(y)):
    c=0
    while y[i]!=n[i+c]:
        if y[i]== n[i+c]:
            l.append(i)
            p+=p0[i+c]
            c+=1
        if y[i] ==  n[i+c]: break

print('total payment', p)

# 0661, 2022-02-24 08:14:55, compilation error (0%)

a = []
b = input()
sum = 0
for b in range q
  if b = 'q':
    b = a.split()
    a.append(b)
    b = input()
    sum += a[b][1]
print('total payment', sum)
# 0662, 2022-02-24 08:16:20, compilation error (0%)

a = []
b = input()
sum = 0
for b in range q
  if b = 'q':
    b = a.split()
    a.append(b)
    b = input()
for i in range len(a):
  for i in range len(b):
    sum += a[a][b]
print('total payment', sum)

# 0663, 2022-02-24 08:09:45, xx (0%)

a = input().split()
c= []
c.append([a[0],a[1]])
count = 0
while a != 'q':
    a= input().split()
    c.append([a[0],a[1]])
b = input().split()

for i in range(len(c)):
    for k in range(len(b)):
        if b[k] == c[i][0]:
            count += float(c[i][1])
        break
print(count)
            
# 0664, 2022-02-24 08:14:58, -- (0%)

a = input().split()
c= []
c.append([a[0],a[1]])
count = 0
while a != 'q':
    a= input()
    if a == 'q':
        break
    if a != 'q':
        a= a.split()
        c.append([a[0],a[1]])

b = input().split()

for i in range(len(c)):
    for k in range(len(b)):
        if b[k] == c[i][0]:
            count += float(c[i][1])
        break
print(count)

# 0665, 2022-02-24 08:15:05, xx (0%)

item = []
price = []
total = 0

while n != "q" :
    y = n.split()
    item.append(y[0])
    price.append(y[1])
    n = input()

order = input().split()
for e in order :
    if e in item :
        m = item.index(e)
        total += float(price[m])
        
print("total payment", str(total))
# 0666, 2022-02-24 08:16:50, xx (0%)

item = []
price = []
total = 0

while n != "q" :
    y = n.split()
    item.append(y[0])
    price.append(y[1])
    n = input()

order = input().split()
for e in order :
    if e in item :
        m = item.index(e)
        total += float(price[m])
        
print("total payment", str(total))

# 0667, 2022-02-24 08:09:39, xx (0%)

x = input().split()
data = []
p = []
while x != 'q':
    data.append(x[0])
    p.append(x[1])
    x = input().split()
l = input().split()
for i in range(len(l)):
    if l[i] == data[i]:
        print('total payment' + str(p[i]))
# 0668, 2022-02-24 08:16:03, xx (0%)

x = input().split()
data = []
p = []
while x != 'q':
    data.append(x[0])
    p.append(x[1])
    x = input().split()

l = input().split()
for i in range(len(l)):
    if l[i] == data[i]:
        a.append(p[i])
        print('total payment' + str(sum(a)))

# 0669, 2022-02-24 08:09:51, x- (0%)

thing=[]
price=[]
n=input()
while n !='q':
    t,p=n=input().split()
    thing.append(t)
    price.append(p)
    n=input()

print('total payment'+str(price))
# 0670, 2022-02-24 08:14:02, x- (0%)

thing=[]
price=[]
n=input()
while n !='q':
    t,p=n=input().split()
    thing.append(t)
    price.append(p)
    n=input()
print(thing)
print('total payment'+str(price))

# 0671, 2022-02-24 08:16:07, xx (0%)

gp =[]
x = input().split()
while x != q:
    good,price.append(x)
goods = []
b = input().split()
goods += b
prices =[]
for i in range(len(good,price)):
    d[i] = good,price.index(b)
    prices.append(d[i+1])
print ('total payment'+sum(prices))

# 0672, 2022-02-24 08:15:22, xx (0%)

a = [e for e in input().split()]
b = []
c = []
while a != 'q':
    
    b += a[0]
    c += float(a[1])
    a = input().split()
    
d = input.split()
e = 0
for i in range(len(b)):
    if b(i) == d(i):
        e += c(i)
        
print('total payment',str(c))
        

# 0673, 2022-02-24 08:11:45, xx (0%)

L=[]
while True:
    x=input().split()
    if x=='q':
        break
    L.append([x[0],x[1]])
show=input().split()
sum=0
j=0
for i in range(len(L)):
    if show[j]==L[i][0]:
        sum+=L[i][1]
        j+=1
print("total payment",sum)



# 0674, 2022-02-24 08:16:03, xx (0%)

ans=0
x=[]
while True:
    x.append(input().split())
    if x[-1]=="q":
        break
y=input().split()
for j in range(len(y)):
    if y[j] in x:
        ans+=x.index(y[j])+1
print("total payment",ans)

# 0675, 2022-02-24 08:13:38, compilation error (0%)

b = input().split()
b = (b[1])
b = 
minb = min(b)
maxb = max(b)
for i in range (minb,maxb):
    i+=i

# 0676, 2022-02-24 08:14:49, xx (0%)

a = []
n = []
m = 0.0
j = 0
while a != ['q']:
    a = input().split()
    n.append(a)
    print(a)
b = input().split()
for i in range(len(n)):
    if j >= len(b):
        break
    if b[j] == n[i][0]:
        c = n.index(b[j][0])
        m += float(n[c][0])
        j += 1
    
print('total payment ' + str(m))

# 0677, 2022-02-24 08:15:51, compilation error (0%)

name=[]
pr=[]
c=0
d=[]
while True:
    x=input()
    if x=="q":
        break
    x=x.split()
    name.append(x[0])
    pr.append(x[1])
y=input().split()
for i in range(len(y)):

# 0678, 2022-02-24 08:16:19, xx (0%)

x=[]
while True :
    e=input().split
    if "q" in x : break
    x=x+e
f=input()


# 0679, 2022-02-24 08:14:20, -x (0%)

x=input().split()

v=[]
al=[]
s=0
while x[0]!='q':        
    v.append(x[0])
    v.append(x[1])
    al.append(v)
    v=[]
    x=input().split()
a=input().split()

for i in range(len(a)-1):
    if a[i]!=a[i+1]:
        s+=float(al[i][1])
    
    
print('total payment',str(s))


# 0680, 2022-02-24 08:10:00, TT (0%)

x = input().split()
l = []
while x != 'q' :
    l.append(x)

y = input().split()
t = 0
for e in y :
    for i in l :
        if e in i : t += float(i[1])
print('total payment',t)


# 0681, 2022-02-24 08:15:16, xx (0%)

n=input().split(' ')
lb=[]
pri=[]
while n!='q':
    lb.append(n[0])
    pri.append(n[1])
    n1=input().split(' ')
    lb.append(n1[0])
    pri.append(n1[1]) 


# 0682, 2022-02-24 08:15:09, -- (0%)

prod = input()
allprod = []
price = 0.0 
while prod != 'q' :
    prod = prod.split()
    allprod.append(prod)
    prod = input()
buy = input().split()
for e in buy :
    if e in allprod :
        price += int(allprod[allprod.index(e)][1])
print('total payment', price)

# 0683, 2022-02-24 08:15:49, xx (0%)

x = input()
s = 0
l = []

while x != q:
    a,b = x.split()
    l.append([a,b])
    x = input()
    
c = input().split()
for i in range(len(c)):
    for e in range(len(l)):
        if c[i] in l[e]:
            s += float(l[e][1])
            
print("total payment",s)

# 0684, 2022-02-24 08:15:36, xx (0%)

p1 = []
p2 = []
x = input().split()
p1.append(x[0])
p2.append(x[1])

while x != ["q"] :
    x = input().split()
    p1.append(x[0])
    p2.append(x[1])

buy = input().split()
bath = []

for i in buy :      
    if i in p1  :
        j = p1.index(i)
        d = p2[j]
        bath.append(int(d))
        
price = 0        
for i in bath :
    price += i

print("total payment" , price)

# 0685, 2022-02-24 08:15:03, xx (0%)

x = input().split()
y = []
Sum = 0
while x != 'q':
    y.append(x)
    x = input().split()

if x == 'q':
    a = input.split()
    for i in range(a):
        for j in range(len(y)):
            if i == (y[j])[0]:
                Sum += (y[j])[1]
    
                
        

print('total payment '+Sum)

# 0686, 2022-02-24 08:14:21, -- (0%)

a = input().split()
b = []
while a != ['q']:
    b.append(a)
    a = input().split()
c = input().split()
d = 0
for e in c:
    if e in b:
        p = b.index(b)
        d += float(b[p+1])
print(d)


# 0687, 2022-02-24 08:15:04, xx (0%)

s = list();S = list() ; b = 0 

while True :
    l = input().split()
    if l[0] == 'q' : break
    S.append(l[0])
    s.append(l)

n = input().split()

for i in range(len(n)) :
    if n[i] in S : b += int(s[S.index(n[i])][1])

print("total payment",b)

# 0688, 2022-02-24 08:16:31, compilation error (0%)

a = list(input().split())
c = 0
while a[0]!=q:
  if b = list(input().split()):
    c+=1

print("total payment" + sum(b[1]) )

# 0689, 2022-02-24 08:15:56, compilation error (0%)


total = 0
while True:
    n = input()
    if n == "q":
        break

    for i in range (len(n)):
    if n != 0:
              total += float(n[i+1])
            

print('total payment ',total)

# 0690, 2022-02-24 08:15:10, -- (0%)

a = []
b = []
x = input()
while x != 'q':
    c,d = x.split()
    a.append(c)
    b.append(d)
    x = input()
sum=0    
e = input().split()
for e in a :
    if e in a:
        i=a.index(e)
        sum=b[i]
print("total payment" , sum)



# 0691, 2022-02-24 08:16:18, xx (0%)

prod = input()
listz=[]
listzname=[]
listzprice=[]
while prod != "q":
    d=prod.split()
    listzname.append(d[0])
    listzprice.append(d[1])
    prod=input()
t=input.split()
s=0
for k in t:
    for i in range(listzname):
        if k == listzname[i]:
            s += float(listzprice[i])
print("total payment",s)

# 0692, 2022-02-24 08:13:04, -- (0%)

x = input()
x1 = x.split()
a = []
z = 0
while  x != 'q':
  a.append(x1)
  x = input()
  x1 = x.split()
print(a)  
y = input().split()
for j in range(len(a)-1):
  if a[j][0] in y:
    z += float(a[j][1])

print('total payment '+str(z) )    
   


# 0693, 2022-02-24 08:14:58, xx (0%)

x = input().split()
grlist = []
price = []
while x != ['q']:
    grlist.append(x[0])
    price.append(x[1])
    x = input().split()
search = input().split()
t = 0
while t in range(len(seach)):
    for i in range(len(grlist)):
          if seach[t] == grlist[i]:
            t += 1
            totalp += price[i]
print("total payment" + totalp)

    

# 0694, 2022-02-24 08:15:38, compilation error (0%)

..

# 0695, 2022-02-24 08:15:33, xx (0%)

d = input()
k = []
while d != 'q' :
    d = d.split()
    k.append(d)
    d = input()

r = input().split()
for e in r:
    for i in range(len(k)):
        c = 0
        if e in k[i]:
            c += float(k[i][1])
print('total payment' + c)

# 0696, 2022-02-24 08:16:15, xx (0%)

x = input()
t = []
p = []
c = 0
while True:
    a,b = x.split()
    x = input()
    if x == 'q':
        break
    t.append(a)
    p.append(float(b))
tt = input().split()
for e in tt:
    c += p[t.index(e)]
print('total payment', t)

# 0697, 2022-02-24 08:10:56, -- (0%)

#maskB 67.125
#maskA 50.0
#mask 50.25
a = input().split()
b= []
if a != 'q':
    a = input().split()
    b.append(a)
c = input().split()
d = 0
for i in range(len(b)):
    for j in range(len(c)):
        if i % 2 == 0:
            if b[i] == c[j]:
                d += int(b[i+1])
                
        

# 0698, 2022-02-24 08:16:07, -- (0%)

s = input()
all = []
price = []
while s != "q":
    x = s.split(" ")
    all.append(x[0])
    price.append(float(x[1]))
    s = input()
to_buy = input().split(" ")

sum = 0
print(all)
print(to_buy)
for i in to_buy:
    for j in range(len(all)):
        if i == all[j]:
            sum += price[j]

print("total payment "+str(sum))



#maskB atk alcoholSpray



# 0699, 2022-02-24 08:15:47, x- (0%)

a = input()
list = []
while a != 'q' :
    b = input().split()
    list.append(a.split())
    a = input()
b = input().split()
price = 0
for j in range (len(b)) :
    for e in range (len(list)) :
            if j == list[e][0] :
                price += float(list[e][1])
print ('total payment',price)

# 0700, 2022-02-24 08:13:35, xx (0%)

a=input().split()
x=[]
y=[]
z=0.0
while a[0]!="q":
    x.append(float(a[1]))
    y.append(a[0])
    a=input().split()

b=input().split

for i in range(len(b)):
    for d in range(len(y)):
      if b[i]==y[d]:
          z+=x[d]
print("total payment", str(z))


# 0701, 2022-02-24 08:15:06, -- (0%)

item = input()
price_l = []
while item!='q':
    name,price = item.split()
    price = float(price)
    price_l.append([name,price])
    item=input()

shopping_l = input().split()
total_price = []
for i in shopping_l:
    for j in price_l:
        if i==j[0]:
            sum(total_price)
print('total payment', sum(total_price))

# 0702, 2022-02-24 08:16:49, -- (0%)

y = []
z = []
while True :
    x = input()
    if x !=  "q" :
        sp = x.split()
        y.append(sp[0])
        z.append(sp[1])
    else :
        break
c = 0
a = input().split()
for e in range(len(y)) :
    if a in y :
        n = y.index(a)
        c += float(z[n])
print("total payment " + str(c))

# 0703, 2022-02-24 08:14:57, -- (0%)

s=''
ss =[]
while s!='q':
  s= input()
  ss.append(s)
ss = ss[:-1]
n=0
b = input().split(' ')
for i in range(len(b)):
  for e in range(len(ss)):
    if b[i] in ss[e][0]:
      n+=float(ss[e][1])
print("total payment",n)

# 0704, 2022-02-24 08:13:54, xx (0%)

d = []
x = input().split
while x != "q":
    d.append(x[0])
    d.append(float(x[1]))
    x = input().split()
y = input.split()
c = 0
for i in range(len(y)):
    for j in range(len(d)):
        if y[i] == x[j]:
            c += x[j+1]

print("total payment"+" "+str(c))



# 0705, 2022-02-24 08:12:45, -- (0%)

a = input()
if a != 'q':
  a = input()

print('total payment' + a[1])

# 0706, 2022-02-24 08:15:51, -- (0%)

x=input().split()
s=[]
for i in range(0,len(x)):
  if x=='q':
    break
  if i%2==0:
    s.append(x[i])
  else:
    s.append(float(x[i]))
  s=input().split()
a=input()
sum=0
for i in range(len(x)):
  if a==x[i]:
    sum+=x[i+1]
print(sum)

# 0707, 2022-02-24 08:15:29, xx (0%)

n = input()
price = []
namelist = []
while n != 'q':
    n.spilt()
    namelist += [n[0]]
    price += [float(n[1])]
    n = input()
    

needed = input()
needed_list = need.spilt()
total = 0
for i in range(len(needed_list)) :
    if needed_list[i] in namelist :
        x = namelist.index(needed_list[i])
        total += price[x]


print('total payment'+str(total))

# 0708, 2022-02-24 08:15:00, xx (0%)

prod = []
price = []
sum = 0
x = input()
while x != 'q':
    pn , p = x.split()
    prod.append(pn)
    price.append(p)
    x = input()

buy = input().split()
for b in buy:
    if b in prod:
        i = prod.index(b)
        for p in price:
            sum += price[p]

print('total payment ' + sum)


# 0709, 2022-02-24 08:15:02, compilation error (0%)

n = input()
d = []
i = 0
while n != 'q':
    d.append([i,[n]])
    n = input()
all = input().split()
i = 0
while i < len(all):
    if all[i] in d[i][0]:
        
        
         
    
    






# 0710, 2022-02-24 08:16:26, -- (0%)

data=[]
x=input()
p=[]
pri=[]
while x!='q':
  a,b=x.split()
  p+=[a]
  pri+=[b]
  x=input()

inp=input()
t=inp.split()
d=[]
for y in t:
  d.append(y)



# 0711, 2022-02-24 08:16:17, -- (0%)

names = input().split()
name = [names[0]]
price = [names[1]]
Sum = 0
while True:
  names = input().split()
  if  names == ["q"] : break
  else: 
      name += [names[0]]
      price += [names[1]]
x = input().split()
for e in x:
  for k in name:
    if e == k[0]:
      Sum += k[1]
print("total payment", Sum)

# 0712, 2022-02-24 08:16:52, xx (0%)

o=input()
a=[]
price_a=[]
while o != "q":
    a.append(o[0])
    price_a.append(o[1])
    o=input()
c=input()
c=c.split()
c_position=[]
for i in range(len(c)):
    cp=a.index(c[i])
    c_position.append(cp)
Ans=[]
for i in range(len(c_position)):
    an=price_a[c_position[i]]
    Ans.append(an)
price=sum(Ans)
print("total payment",price)

# 0713, 2022-02-24 08:15:53, compilation error (0%)

b = []
a = input()
s = 0
while True:
if a != 'q':
  a = a.split()
  b.append(a)
  a = input()
c = input().split()
for i in range(len(c)):
  for j in range(len(b)) :
      if b[j][0] == c[i]:
        s += float(b[j][1])
print('total payment', s)

# 0714, 2022-02-24 08:15:37, compilation error (0%)

price_list = n.split()
price_name = m.split()
space = []
n = ["alcoholGel" 100.5,"mask" 50.2,"atk" 50.2,"maskA"50.2,"maskB" 67.125,"alcoholSpray" 67.125,"q"]
m = [ 100.5,50.2,50.2,50.2,67.125,67.125,67.125,]
for i in range(n):
    x = input()
    if x in price_list:
        for j in range(len(price_list)):
            if price_list[j] == x:
              space.append(price_name[j])


# 0715, 2022-02-24 08:16:32, xx (0%)

a = input().split()
Name =[]
Money =[]
w=[]
while a[0] != "q" :
    a = input().split(" ")
    Name.append(a[0])
    Money.append(a[1])
b =input().split(" ")
for i in b :
    if b in Name :
        w = Name.index(i)

# 0716, 2022-02-24 08:15:08, -- (0%)

a = input()
b = []
while a != 'q':
    a = input()
    b.append(a)
c = []
g = []
for i in range(len(b)):
    d = b[i].split()
    c.append(d[-1])
    g.append(d[0])
e = input().split()
f = 0
for k in range(len(g)):
    if e in g:
        s = b.index(g[k])
        c.index(s)
        f = c+c
        
        


# 0717, 2022-02-24 08:15:21, xx (0%)

n = input()
ans = []
total = 0
for i in range(0,n):
    a = input()
    if a != 'q':
        ans += [a]
    
b = input()
b = e in b.split()
for i in range(len(b)):
  for e in range(len(ans)):
      if ans[e][0] == b[i]:
        total += float(ans[e][1])
print('total payment', total)

# 0718, 2022-02-24 08:15:32, xx (0%)

a = []
num = 0

while True:
    b = input().split()
    if b[0] == "q":
        break
        a.append(b)
    x = input.split()
    for i in range(len(x)):
        num += float(a(b.index(x[i])+1))

# 0719, 2022-02-24 08:14:46, xx (0%)

name = input()
all = []
price = []

for i in name:
  while i != 'q':
    x,y = name.split()
    all = all.append(x)
    price = price.append(y)

    name = input()

buy = input().split()
total = []

for i in buy:
  for j in all:
    if i[0] == j:
      total += j

print('total payment' + total)

# 0720, 2022-02-24 08:16:25, compilation error (0%)

goods = input()
lis_goods = []
while goods != 'q' :
    lis_goods.append(goods)
    goods = input()
lis_goods.append(goods)
lis_goods = lis_goods[:-1]
print(lis_goods)
name = []
price = []
for i in range(0, len(lis_goods)) :
    #print(lis_goods[i])
    inf = lis_goods[i].split(' ')
    #print(inf)
    name.append(inf[0])
    price.append(inf[1])
#print(name)
#print(price)
order = input().split(' ')
lis_order = []
for j in range(0, len(order)) :
    for k in range(0, len(name)) :
        ofder[j] in name[k] :
            price1 = price[k]
price1 = sum(price)
print('total payment '+str(price))


# 0721, 2022-02-24 08:14:22, -- (0%)

manu = input().split()
chosse = input().split()
a = 0
for i in range(len(chosse)):
    if chosse[i] in manu:
        a += int(manu[i+1])
print("total payment", str(a))