c=0

for _ in[0]*int(eval(input())):s=eval(input());n=float(s[:-3]);c+=n*380000*(s[-3]<'J')or n

print(c)
c=0

for s in open(0).readlines()[1:]:n=float(s[:-4]);c+=n*380000*(s[-4]<'J')or n

print(c)
c = 0
for _ in [0] * int(eval(input())):
    s = eval(input())
    n = float(s[:-3])
    c += n * 380000 * (s[-3] < "J") or n
print(c)

c = 0
for s in open(0).readlines()[1:]:
    n = float(s[:-4])
    c += n * 380000 * (s[-4] < "J") or n
print(c)

-for _ in [0] * int(eval(input())): -    s = eval(input()) -    n = float(s[:-3]) -    c += n * 380000 * (s[-3] < "J") or n +for s in open(0).readlines()[1:]: +    n = float(s[:-4]) +    c += n * 380000 * (s[-4] < "J") or n