import Data.List main :: IO () main = do cards <- input_ints let ans = solve cards putStrLn ans input_ints :: IO [Int] input_ints = return . map read . words =<< getLine solve :: [Int] -> String solve cards = solve_rec (sort cards) (0, 0) where solve_rec :: [Int] -> (Int, Int) -> String solve_rec [] count | count == (0, 0) = "NO HAND" | count == (1, 0) = "ONE PAIR" | count == (2, 0) = "TWO PAIR" | count == (0, 1) = "THREE CARD" | count == (1, 1) = "FULL HOUSE" solve_rec (card:cards) (two, three) = solve_rec new_cards (new_two, new_three) where (selected_cards, new_cards) = span (== card) cards (new_two, new_three) = case length selected_cards of 1 -> (two + 1, three) 2 -> (two, three + 1) _ -> (two, three)