n = int(eval(input()))

ans = 0

for _ in range(n):

    x, u = list(map(str, input().split()))

    x = float(x)

    if u == "JPY":

        ans += x

    elif u == "BTC":

        ans += x*380000.0



print(ans)

n = int(eval(input()))

ans = 0

for _ in range(n):

    x, u = list(map(str, input().split()))

    x = float(x)



    if u == "BTC":

        ans += x*380000

    else:

        ans += x

print(ans)

n = int(eval(input()))
ans = 0
for _ in range(n):
    x, u = list(map(str, input().split()))
    x = float(x)
    if u == "JPY":
        ans += x
    elif u == "BTC":
        ans += x * 380000.0
print(ans)

n = int(eval(input()))
ans = 0
for _ in range(n):
    x, u = list(map(str, input().split()))
    x = float(x)
    if u == "BTC":
        ans += x * 380000
    else:
        ans += x
print(ans)

-    if u == "JPY": +    if u == "BTC": +        ans += x * 380000 +    else: -    elif u == "BTC": -        ans += x * 380000.0