import Data.Ratio import Data.List import Control.Monad (%%) n d | d == 0 = Nothing | otherwise = Just (n%d) splitOn :: Int -> [a] -> [[a]] splitOn n = takeWhile (not . null) . unfoldr (return . splitAt n) main = do [h,w] <- map read . words <$> getLine space <- lines <$> getContents putStrLn $ unlines (triangle h w space) triangle h w space = splitOn w $ make h w (x1,y1) (x2,y2) (x,y) where (x,y) = head [(i,j) | i<-[0..h-1], j<-[0..w-1], valid (x1,y1) (x2,y2) (i,j)] [(x1,y1),(x2,y2)] = map snd $ filter ((=='*') . fst) $ zip (concat space) [(i,j) | i<-[0..h-1], j<-[0..w-1]] valid p1@(x1,y1) p2@(x2,y2) p3@(i,j) = ((x1-i)%%(y1-j) /= (x2-i)%%(y2-j)) && distinct [p1,p2,p3] make h w p1 p2 p3 = [c | i<-[0..h-1], j<-[0..w-1], let c = if elem (i,j) [p1,p2,p3] then '*' else '-'] distinct xs = let sxs = sort xs in and $ zipWith (/=) sxs (tail sxs)