import qualified Data.IntMap as M import Data.List import Control.Monad (!?) im v = M.findWithDefault [] v im main = do [n,_] <- map read . words <$> getLine abs <- map (map read . words) . lines <$> getContents let g = buildG abs print (shikaku n g) buildG = foldr (\[a,b] acc -> M.insertWith (++) a [b] (M.insertWith (++) b [a] acc)) M.empty shikaku n g = length $ do v1 <- [0 .. n-1] v2 <- [v1+1 .. n-1] v3 <- [v2+1 .. n-1] v4 <- [v3+1 .. n-1] let ws1 = intersect (g!?v1) [v2,v3,v4] let ws2 = intersect (g!?v2) [v1,v3,v4] let ws3 = intersect (g!?v3) [v1,v2,v4] let ws4 = intersect (g!?v4) [v1,v2,v3] guard $ map length (group (sort (concat [ws1,ws2,ws3,ws4]))) == [2,2,2,2]