main = interact main'

main' :: String -> String
main'
    = show . f . map read . words . head . lines

f :: [Integer] -> Integer
f [a, b] = (g a) + (g b) + (h a b)

g 1 = 300000
g 2 = 200000
g 3 = 100000
g _ = 0

h 1 1 = 400000
h _ _ = 0