import Control.Monad
import Data.Array.IArray
import Data.Array.ST
import Data.Bool
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . show

sol ([n,ma,mb]:abcs) = bool (-1) c (c < n*maxc)
  where
  tbl = dp (n*maxab) (n*maxc) abcs
  c = minimum . fmap (tbl!) . takeWhile (\(a,b) -> max a b<=n*maxab) $
    fmap ((,) <$>  (*ma) <*> (*mb)) [1..] 

maxab = 10 :: Int
maxc = 100 :: Int

dp sz mx abcs = runSTUArray $ do
  tbl <- newArray ((0,0),(sz,sz)) (mx :: Int)
  writeArray tbl (0,0) 0
  forM_ abcs $ \[a,b,c] -> do
    forM_ [0..sz-a] $ \i -> do
      forM_ [0..sz-b] $ \j -> do
        v <- readArray tbl (i,j)
        when (v<mx) $ do
          v' <- readArray tbl (i+a,j+b)
          writeArray tbl (i+a,j+b) (min v' (v+c))
  return tbl