import Control.Applicative import Data.Maybe import Data.Array dfs :: Array (Int,Int) (Maybe String) ->Int -> Int -> Int -> [Int] -> Maybe String dfs memo t n v [] | v == t = Just "" | otherwise = Nothing dfs memo t n v (x:xs) | v+x <= t && (isJust $ memo!(n+1,v+x)) = Just ('+':(fromJust $ memo!(n+1,v+x))) | v*x <= t && (isJust $ memo!(n+1,v*x)) = Just ('*':(fromJust $ memo!(n+1,v*x))) | otherwise = Nothing main :: IO() main = do n <- read <$> getLine total <- read <$> getLine (s:a) <- map read . words <$> getLine let memo = array ((1,s),(n,total)) [((i,j),dfs memo total i j $ drop i a) | i<-[1..n],j<-[s..total] ] putStrLn $ fromJust $ dfs memo total 0 s a