module Main (main) where import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty(..), (<|)) import qualified Data.Set as Set import Input splitOn :: (a -> Bool) -> [a] -> NonEmpty [a] splitOn _ [] = [] :| [] splitOn f (x:xs) | f x = [] <| splitOn f xs | otherwise = let l :| ls = splitOn f xs in (x : l) :| ls main :: IO () main = do input <- getInput 6 let groups = map (map Set.fromList) (NE.toList (splitOn null input)) print (sum (map (Set.size . Set.unions) groups)) print (sum (map (Set.size . foldl1 Set.intersection) groups))