N = int(eval(input()))

ans = 0

for _ in range(N):

    x, u = input().split()

    if u == 'JPY':

        ans += float(x)

    elif u == 'BTC':

        ans += float(x) * 380000.0

print(ans)
N = int(eval(input()))

ans = 0.0

for _ in range(N):

    x, u = input().split()

    if u == 'JPY':

        ans += float(x)

    elif u == 'BTC':

        ans += float(x) * 380000.0

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

N = int(eval(input()))
ans = 0.0
for _ in range(N):
    x, u = input().split()
    if u == "JPY":
        ans += float(x)
    elif u == "BTC":
        ans += float(x) * 380000.0
print(ans)

-ans = 0 +ans = 0.0