import Data.List (sort) main :: IO () main = interact $ solve . reverse . sort . map length . sort . words where solve (3 : 2 : _) = "FULL HOUSE" solve (3 : _) = "THREE CARD" solve (2 : 2 : _) = "TWO PAIR" solve (2 : _) = "ONE PAIR" solve _ = "NO HAND"