import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List cards = new ArrayList<>(); for (int i = 0; i < 5; i++) { cards.add(Integer.parseInt(sc.next())); } if (isFullHouse(cards)) { System.out.println("FULL HOUSE"); } else if (isThreeCard(cards)) { System.out.println("THREE CARD"); } else if (isTwoPair(cards)) { System.out.println("TWO PAIR"); } else if (isOnePair(cards)) { System.out.println("ONE PAIR"); } else { System.out.println("NO HAND"); } } private static boolean isFullHouse(List cards) { Map match = calcCards(cards); return match.size() == 2 && match.containsValue(3); } private static boolean isThreeCard(List cards) { Map match = calcCards(cards); return match.containsValue(3); } private static boolean isTwoPair(List cards) { Map match = calcCards(cards); return match.size() == 3 && !match.containsValue(3); } private static boolean isOnePair(List cards) { Map match = calcCards(cards); return match.size() == 4; } private static Map calcCards(List cards) { Map match = new HashMap<>(); for (Integer card : cards) { if (!match.containsKey(card)) { match.put(card, 0); } match.put(card, match.get(card) + 1); } return match; } }