64_2_PCG_06

Max Score = 100


6432021021
# 1538504, 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)
# 1538515, 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)
# 1538562, 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)
# 1538613, 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)
# 1538644, 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)
# 1538720, 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)
# 1538889, 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)
# 1538961, 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)
# 1538989, 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)

6430412421
# 1538541, 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)            
# 1538551, 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)            
# 1538818, 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)            
# 1538841, 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)
# 1539028, 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)            
# 1539046, 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)
# 1539119, 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)            

6432009621
# 1538697, 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:
# 1538830, 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)
# 1538880, 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)
# 1538907, 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)
# 1538958, 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)
# 1538985, 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)
# 1539030, 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)

6430296021
# 1538412, 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))

# 1538448, 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))

# 1538478, 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))

# 1538532, 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))

# 1538571, 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))

# 1538660, 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))


6430333521
# 1538709, 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)
    
# 1538753, 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)
    
# 1538829, 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)
# 1538873, 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)
# 1538914, 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)
# 1538965, 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)

6430370721
# 1538406, 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))
# 1538424, 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))
# 1538427, 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))
# 1538458, 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))
# 1538573, 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))
# 1538626, 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))

6430316921
# 1538521, 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)
# 1538539, 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)
# 1538574, 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)
# 1538654, 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)
# 1538677, 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)

6430345021
# 1538792, 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)
# 1538813, 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)
# 1539093, 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)
# 1539108, 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)
# 1539121, 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)

6430394821
# 1538680, 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)
  

# 1538711, 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)
# 1538760, 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)
# 1538840, 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)
# 1538976, 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)

6430396021
# 1538694, 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))    


# 1538781, 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))
# 1538906, 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))    

# 1538920, 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))
# 1538954, 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))    




6430438821
# 1538661, 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)

# 1538682, 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)
# 1538842, 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)
# 1538850, 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)
# 1538956, 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)

6432063421
# 1538714, 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)
# 1538745, 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)
# 1538835, 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)
# 1539004, 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)
# 1539077, 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)

6432119021
# 1538457, 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)
    
# 1538489, 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)
# 1538496, 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)
# 1538517, 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)
# 1538600, 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)

6432196221
# 1538696, 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))

# 1538784, 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))

# 1539069, 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))

# 1539111, 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))
# 1539122, 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))

6430164821
# 1538737, 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}')
# 1538814, 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}')
# 1538864, 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)
# 1538942, 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))

6430247221
# 1538554, 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))

# 1538580, 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))
# 1538722, 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))
# 1538911, 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))

6430273521
# 1538440, 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
    


# 1538446, 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
    


# 1538509, 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
    
# 1538630, 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)
    



6430278721
# 1538874, 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)

        
    
    


# 1538905, 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)
# 1538969, 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))
# 1538981, 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))

6430279321
# 1538599, 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)
# 1538730, 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)
# 1538947, 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)
# 1539042, 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)

6430312321
# 1538656, 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)
        

# 1538785, 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))
        

# 1538876, 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))
        

# 1538902, 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))

6430323221
# 1538474, 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)

# 1538519, 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))
# 1538651, 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)


# 1538805, 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)



6430332921
# 1538566, 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)
    


# 1538721, 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)



# 1538746, 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)



# 1538903, 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)




6430335821
# 1538839, 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)
# 1538931, 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)
# 1539055, 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)
# 1539083, 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)

6430386821
# 1538414, 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)
# 1538429, 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)
# 1538465, 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)
# 1538557, 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)

6432041621
# 1538402, 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)
# 1538452, 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)
# 1538492, 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)
# 1538627, 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)

6432054821
# 1538716, 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}')

# 1538853, 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}')
# 1538944, 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}')
# 1539002, 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))

6432166421
# 1538700, 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)
    

# 1538741, 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)
    

# 1538748, 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)
# 1538807, 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)
    


6432167021
# 1539037, 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)

# 1539051, 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)
# 1539062, 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)
# 1539075, 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)


6432178021
# 1538636, 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)
# 1538648, 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)
# 1538806, 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)
# 1539033, 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)

6430173421
# 1538669, 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)
        

        

# 1538684, 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)
# 1538728, 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)

6430193021
# 1538901, 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)
# 1538938, 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))
# 1539089, 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)

6430197521
# 1538408, 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)
# 1538418, 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)
# 1538444, 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)

6430225421
# 1538479, 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)
# 1538501, 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)
# 1538511, 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)

6430231121
# 1538454, 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())
# 1538482, 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))
# 1538589, 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))

6430264921
# 1538413, 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)
# 1538423, 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))
# 1538442, 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))

6430284421
# 1538483, 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)

# 1538505, 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)
# 1538756, 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)

6430334121
# 1538663, 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)
# 1538759, 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)
# 1539045, 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)

6430353021
# 1538683, 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)
# 1538733, 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)
# 1539008, 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)

6430395421
# 1538872, 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)
    



# 1538879, 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)
# 1538913, 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)

6430397721
# 1538833, 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)

# 1539020, 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)
# 1539057, 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)

6430433621
# 1538455, 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)

# 1538547, 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)

# 1538576, 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)


6432022721
# 1538421, 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)

# 1538585, 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)


# 1538655, 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)



6432087521
# 1538560, 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 ',)


# 1538567, 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)
# 1538770, 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)



6432092621
# 1538643, 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)
# 1538804, 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  )
# 1538962, 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  )

6432134321
# 1538592, 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))
# 1538679, 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))
# 1538849, 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))

6432141721
# 1538793, 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)

# 1538912, 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)
# 1538977, 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)

6432165821
# 1538775, 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")
# 1538819, 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)
# 1538866, 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)

6432190421
# 1538410, 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)
# 1538428, 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)
# 1538629, 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)

6430163121
# 1538545, 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)

# 1538558, 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)

6430174021
# 1538407, 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))
# 1538419, 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))

6430201321
# 1538794, 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))


# 1538851, 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))

6430203621
# 1538431, 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)
# 1538467, 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)

6430212221
# 1538481, 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))
  
# 1538529, 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))

6430218021
# 1538434, 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))
# 1538461, 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))

6430246621
# 1538533, 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)





# 1538691, 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))






6430289621
# 1538463, 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)
# 1538494, 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))

6430302021
# 1538597, 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))

# 1538693, 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))

6430308921
# 1538635, 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)
# 1538664, 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)

6430314621
# 1538717, 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)
# 1538934, 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)

6430315221
# 1538456, 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)   
    

# 1538525, 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)   
    


6430364021
# 1538751, 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)
# 1538811, 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)

6430365621
# 1538882, 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))
# 1538968, 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))

6430367921
# 1538523, 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)
# 1538591, 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)

6430368521
# 1538715, 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)
    

# 1538780, 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)
    


6430373621
# 1538534, 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)
# 1538797, 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)

6430379421
# 1538622, 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))

# 1538637, 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))

6430383921
# 1538550, 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)
# 1538650, 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)

6430408021
# 1538491, 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)


# 1538624, 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)

6430429121
# 1538688, 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)
# 1538729, 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)




6430443921
# 1538974, 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))
# 1539039, 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))

6430446821
# 1538706, 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))

        
    

# 1538787, 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))

        
    


6430452521
# 1538685, 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)


# 1538857, 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)



6432012421
# 1538553, 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)
# 1538955, 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)

6432035921
# 1538450, 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)
# 1538499, 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)

6432037121
# 1538786, 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) 
# 1538802, 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)

6432044521
# 1538564, 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)
# 1538739, 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)

6432048021
# 1538666, 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)
# 1538761, 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)

6432056021
# 1538774, 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)


# 1538846, 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)



6432062821
# 1538701, 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)
# 1538755, 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)

6432093221
# 1538628, 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)
# 1538676, 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)

6432104521
# 1538542, 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) 
# 1538690, 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)

6432106821
# 1538634, 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)
# 1538657, 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)

6432111921
# 1538917, 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)
# 1539084, 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)

6432122821
# 1538508, 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)
    
    
# 1538535, 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)
    


6432140021
# 1538420, 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)
# 1538438, 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)

6432148121
# 1539023, 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)
# 1539082, 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))

6432155521
# 1538865, 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))
# 1539035, 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))

6432157821
# 1538594, 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)
# 1538611, 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)

6432158421
# 1538409, 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)
    
# 1538468, 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)


6432164121
# 1538939, 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)
# 1539049, 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)

6432170921
# 1538712, 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)
    
    

# 1539071, 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)

6432200021
# 1539059, 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)


# 1539110, 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)

6430166021
# 1538672, 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))


6430167721
# 1538703, 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))


6430171121
# 1538892, 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)

6430176321
# 1539001, 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)

6430178621
# 1538484, 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))
  


6430183721
# 1538623, 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)
        

6430184321
# 1539000, 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)


6430185021
# 1538559, 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)
    

6430188921
# 1538740, 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)

6430189521
# 1538768, 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)

6430190021
# 1538689, 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)
    

6430191721
# 1538485, 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)
            


6430192321
# 1539104, 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)


6430196921
# 1538477, 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)

6430198121
# 1538620, 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)


6430202021
# 1538565, 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)))


6430204221
# 1538584, 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))

6430205921
# 1538702, 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)

6430207121
# 1538497, 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))

6430208821
# 1538869, 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)

6430211621
# 1538430, 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)

6430213921
# 1538870, 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)   

6430215121
# 1538403, 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))

6430216821
# 1538561, 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)

6430220221
# 1538695, 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)


6430221921
# 1538596, 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'))



6430222521
# 1538670, 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)
            


6430226021
# 1538586, 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)


6430228321
# 1538516, 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))

6430229021
# 1538808, 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)

6430230521
# 1538826, 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)

6430235721
# 1538815, 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))

6430237021
# 1538617, 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)

6430239221
# 1538498, 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)

6430241421
# 1538473, 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)

6430243721
# 1538411, 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)

6430245021
# 1539095, 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)

6430248921
# 1538563, 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))

6430250021
# 1538510, 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)

6430251721
# 1538649, 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)

6430253021
# 1538460, 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)

6430254621
# 1538754, 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)
        
        

6430255221
# 1538641, 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)

6430256921
# 1538472, 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))

6430267821
# 1538500, 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)
    

6430268421
# 1538764, 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)
        

6430269021
# 1538443, 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)

6430270621
# 1538888, 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()

6430272921
# 1538713, 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)

6430274121
# 1538514, 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)

6430281521
# 1538462, 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))

6430282121
# 1538404, 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)


6430283821
# 1538480, 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)


6430285021
# 1538653, 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))



6430288021
# 1538665, 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)

6430290121
# 1538549, 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)

6430293021
# 1538503, 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))
        



6430295321
# 1538475, 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)

6430300821
# 1538881, 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)


6430306621
# 1538543, 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)


6430313021
# 1538502, 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)

6430318121
# 1538782, 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)))

6430321021
# 1538607, 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)

6430322621
# 1538844, 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))
     


6430324921
# 1538417, 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))

6430325521
# 1538749, 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)

6430326121
# 1538799, 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)

6430330621
# 1538856, 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)
        



6430331221
# 1538735, 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)) 

6430336421
# 1539120, 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)


6430337021
# 1538894, 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)

6430339321
# 1539003, 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)



6430341521
# 1538459, 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)
    


6430343821
# 1538708, 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))

6430425621
# 1538486, 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)

6430346721
# 1538621, 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)



6430349621
# 1538466, 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)

6430354721
# 1538476, 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)

6430357621
# 1538451, 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)

6430358221
# 1538548, 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))

6430361021
# 1538568, 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)
    

6430366221
# 1538616, 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))

6430369121
# 1538577, 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)

6430372021
# 1538674, 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)

6430376521
# 1538445, 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)     

6430377121
# 1538527, 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)

6430378821
# 1538778, 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))

6430380021
# 1538777, 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)



6430381621
# 1538588, 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))

6430384521
# 1538441, 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))

6430385121
# 1538405, 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)

6430388021
# 1538436, 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)
    


6430392521
# 1538435, 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)


6430393121
# 1538662, 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)

6430398321
# 1538520, 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)

6430399021
# 1538614, 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)


6430401521
# 1538575, 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)

    


6430403821
# 1538832, 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))


6430404421
# 1539007, 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)

6430405021
# 1538437, 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)


6430406721
# 1538686, 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)


6430407321
# 1538528, 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)

6430411821
# 1538453, 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)


6430413021
# 1538707, 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))

6430415321
# 1538758, 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)

6430416021
# 1538845, 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)

6430417621
# 1538582, 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))

6430420421
# 1538738, 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)

6430421021
# 1538449, 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)

6430426221
# 1538750, 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)

6430428521
# 1538490, 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)

6430431321
# 1538731, 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)

6430435921
# 1538544, 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)

6430439421
# 1538915, 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)

6430441621
# 1538619, 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)

6430453121
# 1538633, 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))

6432001521
# 1538602, 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)

6432003821
# 1538524, 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))

6432004421
# 1538587, 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))

6432006721
# 1538877, 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)

6432008021
# 1538606, 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))


6432010121
# 1538555, 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))

6432013021
# 1538593, 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))

6432018221
# 1538825, 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)

6432020421
# 1538604, 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)

6432027921
# 1538699, 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))

6432029121
# 1538827, 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))

6432031321
# 1538538, 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)

6432033621
# 1538522, 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)


6432034221
# 1538537, 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)

6432040021
# 1538469, 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))

6432042221
# 1538953, 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)

6432049721
# 1538583, 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))

6432057721
# 1538612, 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)

6432058321
# 1538530, 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)
    
    


6432065721
# 1538687, 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)



6432066321
# 1538512, 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))

6432067021
# 1538470, 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)

6432069221
# 1538632, 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)


6432072021
# 1538425, 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)
        


6432074321
# 1539117, 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)


6432080021
# 1538647, 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))

6432089821
# 1538862, 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)

6432091021
# 1538980, 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)

6432095521
# 1538927, 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)

6432096121
# 1538858, 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)

6432099021
# 1538762, 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)


6432108021
# 1538495, 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))

6432109721
# 1538569, 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)

6432113121
# 1538638, 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))
    

6432115421
# 1538487, 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))

6432116021
# 1539076, 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)


6432118321
# 1538925, 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) 

6432123421
# 1538605, 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)


6432126321
# 1538422, 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))

6432128621
# 1538518, 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))


6432129221
# 1538698, 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))

6432131421
# 1538816, 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))


6432135021
# 1538507, 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)        
    


6432139521
# 1538556, 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)


6432143021
# 1539053, 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))


6432146921
# 1538668, 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))

6432147521
# 1538416, 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)

6432160621
# 1538645, 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)


6432161221
# 1538678, 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))


6432163521
# 1538488, 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))

6432168721
# 1538432, 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)


6432174421
# 1538610, 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))

6432181821
# 1538667, 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)



6432186021
# 1538916, 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))

6432193321
# 1538531, 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))


6432199121
# 1538724, 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


6430234021
# 1538415, 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)
# 1538439, 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)
# 1538471, 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)
# 1538526, 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)
# 1538552, 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)
# 1538590, 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)
# 1538673, 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)
# 1538726, 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)

# 1538743, 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)
# 1538763, 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)
# 1538821, 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)

6430182021
# 1539036, 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)

6430200721
# 1538618, 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))

6432075021
# 1538658, 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


6430271221
# 1538732, 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)
# 1538769, 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)
# 1538810, 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))
# 1538823, 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)
# 1538847, 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)
# 1538885, 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)
# 1538919, 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))
# 1538996, 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}')

6430286721
# 1538536, 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))
# 1538579, 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))
# 1538639, 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))
# 1538659, 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))
# 1538675, 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))
# 1538736, 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))

# 1538791, 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))
# 1538959, 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))

6430214521
# 1538757, 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)
    
    
    



# 1538783, 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)
# 1538855, 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)
# 1538871, 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)
# 1538948, 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)
# 1538995, 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)
# 1539061, 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)

6432121121
# 1538447, 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)
# 1538464, 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)
# 1538493, 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)
# 1538609, 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))
# 1538932, 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))
# 1539068, 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))
# 1539096, 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))

6430287321
# 1538603, 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))       
# 1538796, 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))
# 1538848, 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)
# 1538868, 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)
# 1538929, 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)
# 1538979, 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)

6430449721
# 1538546, 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))
# 1538581, 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))
# 1538681, 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))


# 1538771, 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))


# 1538893, 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))
# 1538921, 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))

6430244321
# 1538875, 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)}')

# 1538897, 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)}')
# 1538986, 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)}')
# 1539041, 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)}')
# 1539081, 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)}')

6430299921
# 1538513, 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))
        
# 1538540, 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))
# 1538692, 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))
# 1538742, 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))
# 1538935, 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))

6430350121
# 1538798, 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)
# 1538837, 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)
# 1538859, 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)
# 1538896, 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)
# 1539074, 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)

6430356021
# 1538704, 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)
# 1538725, 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)
# 1538776, 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)
# 1538898, 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)
# 1539014, 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))

6432150321
# 1538631, 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)
# 1538860, 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)
    
# 1538890, 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)
# 1538975, 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)
# 1539034, 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)

6430223121
# 1538788, 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)
# 1538987, 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)
# 1539016, 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)
# 1539080, 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)

6430258121
# 1538646, 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))
# 1538767, 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))
# 1538790, 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))
# 1538923, 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))

6430309521
# 1538884, 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)
# 1538940, 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)
# 1538984, 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)
# 1539029, 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)

6432017621
# 1538752, 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)

# 1538812, 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)

# 1538922, 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)

# 1539072, 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)


6432053121
# 1538765, 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))
# 1538795, 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))
# 1539065, 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)
# 1539109, 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))

6432068621
# 1538744, 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)
# 1538843, 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)
# 1539013, 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)
        
# 1539106, 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)
        

6432088121
# 1538598, 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))

# 1538891, 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))

# 1538949, 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))

# 1539017, 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))


6430172821
# 1538809, 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)
    
# 1539044, 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)
# 1539063, 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)

6430199821
# 1538652, 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)
# 1538836, 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)
# 1538908, 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)


6430360421
# 1538883, 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)
# 1538998, 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)
# 1539070, 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)

6430390221
# 1538723, 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))

# 1538926, 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))
# 1539094, 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))

6430419921
# 1538615, 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 )  
# 1538909, 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 )  
# 1539038, 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 )

6430424021
# 1538642, 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)
# 1538734, 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)
# 1538854, 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)

6430427921
# 1538988, 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))
# 1539032, 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))
# 1539087, 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))

6430430721
# 1538719, 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])
# 1538773, 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)
# 1538803, 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)

6432005021
# 1538838, 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)
# 1538878, 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)
# 1538971, 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)

6432036521
# 1538570, 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

# 1538861, 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 ()
# 1538966, 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)

6432039421
# 1538433, 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)
# 1538831, 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)

# 1539101, 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)


6432052521
# 1538972, 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)
  
# 1538997, 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)
    
# 1539009, 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)

6432081721
# 1538990, 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))
# 1539073, 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))
# 1539103, 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))

6432112521
# 1538772, 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")
# 1538800, 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")
# 1539025, 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))

6432120521
# 1538960, 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  
# 1538983, 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
# 1539105, 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)

6432136621
# 1538640, 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)        
# 1538789, 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)   
# 1538820, 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)        

6432149821
# 1538572, 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)
# 1538747, 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)
# 1539115, 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)

6430292421
# 1538867, 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)
        


# 1538992, 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)

6430162521
# 1538936, 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)
# 1539050, 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)

6430169021
# 1538822, 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)   
# 1539064, 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)

6430179221
# 1538924, 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)
# 1539024, 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)

6430186621
# 1539019, 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)
# 1539054, 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))

6430233421
# 1538933, 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)
# 1539027, 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)

6430238621
# 1538426, 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)
# 1538578, 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)

6430259821
# 1538727, 2022-02-24 08:11:59, -- (0%)

d=[]
n=input()
while n != 'q':
    d.append(n)
    n=input()
# 1539012, 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]
        

6430260321
# 1539005, 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)
# 1539085, 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)

6430262621
# 1538824, 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)
# 1539031, 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)


6430263221
# 1538994, 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)
# 1539011, 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)

6430319821
# 1539056, 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)
  


# 1539118, 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)
  



6430351821
# 1538710, 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])
# 1539113, 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))

6430375921
# 1538766, 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))
# 1538886, 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))

6430418221
# 1539058, 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)
# 1539102, 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)

6430423321
# 1538887, 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)
# 1538918, 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)

6432002121
# 1538904, 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))
# 1539018, 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))


6432014721
# 1538705, 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)
# 1538910, 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)

6432016021
# 1538506, 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) )
# 1538978, 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)

6432102221
# 1538817, 2022-02-24 08:13:23, -- (0%)

x = input()
d = []
while x != "q" :
    d.append(x)
    x = input()
    print(x)
# 1538999, 2022-02-24 08:15:24, -- (0%)

x = input()
d = []
while x != "q" :
    d.append(x)
    x = input()
print(d)
    

6432151021
# 1538951, 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)
# 1539107, 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)

6432185321
# 1538937, 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)
# 1539092, 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)

6432189921
# 1538601, 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)
            
# 1538945, 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)

6432192721
# 1538963, 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))
# 1539114, 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))

6432194021
# 1538595, 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]))
# 1539066, 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)))

6432201721
# 1538608, 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))
# 1538863, 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))

6430165421
# 1539079, 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))

6430168321
# 1538993, 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))
        

6430177021
# 1538718, 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)



6430180821
# 1539067, 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)

6430187221
# 1538834, 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

6430194621
# 1538930, 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))

6430206521
# 1539047, 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)):

6430209421
# 1539091, 2022-02-24 08:16:19, xx (0%)

x=[]
while True :
    e=input().split
    if "q" in x : break
    x=x+e
f=input()


6430210021
# 1538895, 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))


6430217421
# 1538625, 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)


6430242021
# 1538982, 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]) 


6430249521
# 1538970, 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)

6430252321
# 1539043, 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)

6430257521
# 1539021, 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)

6430261021
# 1538952, 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)

6430276421
# 1538899, 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)


6430277021
# 1538957, 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)

6430291821
# 1539099, 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]) )

6430298221
# 1539060, 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)

6430328421
# 1538973, 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)



6430338721
# 1539090, 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)

6430344421
# 1538801, 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) )    
   


6430347321
# 1538943, 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)

    

6430348021
# 1539026, 2022-02-24 08:15:38, compilation error (0%)

..

6430362721
# 1539015, 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)

6430374221
# 1539086, 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)

6430382221
# 1538671, 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])
                
        

6430387421
# 1539078, 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



6430389721
# 1539040, 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)

6430391921
# 1538828, 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))


6430409621
# 1538964, 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))

6430422721
# 1539112, 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))

6430442221
# 1538941, 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)

6430444521
# 1538852, 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))



6430450221
# 1538779, 2022-02-24 08:12:45, -- (0%)

a = input()
if a != 'q':
  a = input()

print('total payment' + a[1])

6432007321
# 1539048, 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)

6432011821
# 1539006, 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))

6432028521
# 1538946, 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)


6432032021
# 1538950, 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]:
        
        
         
    
    






6432038821
# 1539098, 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)



6432043921
# 1539088, 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)

6432076621
# 1539116, 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)

6432097821
# 1539052, 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)

6432103921
# 1539022, 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])


6432105121
# 1539100, 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)

6432107421
# 1538967, 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
        
        


6432176721
# 1538991, 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)

6432182421
# 1539010, 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))

6432183021
# 1538928, 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)

6432198521
# 1539097, 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))


6432203021
# 1538900, 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))