n = int(eval(input()))

ans = 0

for i in range(n):

    x,u = input().split()

    x = float(x)

    ans += x if u=='JPY' else x*380000

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

ans = 0

for i in range(n):

    x,u = input().split()

    x = float(x)

    if u=='JPY':

        ans += x

    else:

        ans += x* 380000

print(ans)

n = int(eval(input()))
ans = 0
for i in range(n):
    x, u = input().split()
    x = float(x)
    ans += x if u == "JPY" else x * 380000
print(ans)

n = int(eval(input()))
ans = 0
for i in range(n):
    x, u = input().split()
    x = float(x)
    if u == "JPY":
        ans += x
    else:
        ans += x * 380000
print(ans)

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