{- Author: Robin Nittka -}
{-# OPTIONS_GHC -O2 #-}

module Main
	where

import System.IO
import Data.Ratio
import Data.List

type Rat = Ratio Integer

split :: [String] -> [(Rat,Rat,[Integer])]
split [] = []
split (_:y:z:xs) = (a, b, map read $ words z):split xs
	where [a,b] = map (fromInteger . read) $ words y

solve :: (Rat,Rat,[Integer]) -> Rat
solve (a,b,s) = minimum $ map evaluate poss
	where
		m = maximum s
		poss = map head $ group $ sort $ filter (>= m%3) [ x%p | x <- s, p <- [1..3] ]
		evaluate size = sum $ map (evaluate' size) s
		evaluate' size stud = a*x + b*y
			where
				y = fromInteger $ ceiling $ (fromInteger stud) / size
				x = y * size - (fromInteger stud)

render :: Rat -> String
render q = case denominator q of
	1 -> show $ numerator q
	otherwise -> (show $ numerator q) ++ " / " ++ (show $ denominator q)

main :: IO ()
main = do
	file <- openFile "food.in" ReadMode
	hGetContents file >>= mapM_ (putStrLn . render . solve) . split . init . lines
