Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
n = int(input())
jpy = 0
btc = 0
for _ in range(n):
  x,y = input().split()
  z = x.split('.')
  x = z[0]
  if y == 'JPY':
    jpy += int(x)
  else:
    btc += int(x)
print(jpy + btc * 380000.0)
n = int(input())
jpy = 0
btc = 0
for _ in range(n):
  x,y = input().split()
  if y == 'JPY':
    jpy += int(x)
  elif y == 'BTC':
    btc += float(x)
print(jpy + btc * 380000.0)