import Control.Monad import Data.List main = getLine >>= print . solve . map read . words solve :: [Int] -> Double solve [p, c] = fromIntegral a / fromIntegral b where ff (acc, m) x = (head x * len + acc, m + len) where len = length x (a, b) = foldl ff (0, 0) muls muls = group . sort . foldl (liftM2 (*)) [1] $ replicate p [2, 3, 5, 7, 11, 13] ++ replicate c [4, 6, 8, 9, 10, 12]