N = int(eval(input()))

JPY = 0

BTC = 0

for _ in range(N):

    a = list(input().split())

    if a[1] == 'JPY': JPY += int(a[0])

    else: BTC += float(a[0])

print((float(JPY + BTC*380000.0)))
n = int(eval(input()))

money = [input().split() for _ in range(n)]

print((sum([float(x)*{"JPY":1, "BTC":380000}[u] for x,u in money])))
N = int(eval(input()))
JPY = 0
BTC = 0
for _ in range(N):
    a = list(input().split())
    if a[1] == "JPY":
        JPY += int(a[0])
    else:
        BTC += float(a[0])
print((float(JPY + BTC * 380000.0)))

n = int(eval(input()))
money = [input().split() for _ in range(n)]
print((sum([float(x) * {"JPY": 1, "BTC": 380000}[u] for x, u in money])))

-N = int(eval(input())) -JPY = 0 -BTC = 0 -for _ in range(N): -    a = list(input().split()) -    if a[1] == "JPY": -        JPY += int(a[0]) -    else: -        BTC += float(a[0]) -print((float(JPY + BTC * 380000.0))) +n = int(eval(input())) +money = [input().split() for _ in range(n)] +print((sum([float(x) * {"JPY": 1, "BTC": 380000}[u] for x, u in money])))