import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Sample121 {
	private static final String RANK_LIST = "A23456789TJQKA";

	private static final String ROYAL = "royal ";
	private static final String STRAIGHT = "straight";
	private static final String FLUSH = "flush";
	private static final String FULL_HOUSE = "Full house";
	private static final String CARDS_4 = "Four of a kind";
	private static final String CARDS_3 = "Three of a kind";
	private static final String PAIR_2 = "Two pair";
	private static final String PAIR_1 = "One pair";
	private static final String Nothing = "No pair";

	public static String getPokerRole(String cards) {
		if (cards.length() != 2 * 5) throw new IllegalArgumentException();
		String rankList = createRankList(cards);
		boolean flush = isFlush(cards);
		boolean straight = isStraight(rankList);
		if (flush || straight) {
			boolean royal = isRoyal(rankList);
			if (royal) {
				return format(flush? ROYAL + FLUSH: ROYAL + STRAIGHT);
			} else {
				if (flush && straight) {
					return format(STRAIGHT + " " + FLUSH);
				} else {
					return format(flush? FLUSH: STRAIGHT);
				}
			}
		}
		Integer[] integers = countSameNumber(rankList);
		switch (integers[0]) {
			case 4:
				return CARDS_4;
			case 3:
				if (integers[1] == 2) {
					return FULL_HOUSE;
				} else {
					return CARDS_3;
				}
			case 2:
				if (integers[1] == 2) {
					return PAIR_2;
				} else {
					return PAIR_1;
				}
		}
		return Nothing;
	}

	private static String format(String str) {
		return str.substring(0, 1).toUpperCase() + str.substring(1);
	}

	private static boolean isFlush(String cards) {
		char suit = cards.charAt(0);
		for (int index = 1; index < 5; index++) {
			if (suit != cards.charAt(index * 2)) {
				return false;
			}
		}
		return true;
	}

	private static String createRankList(String cards) {
		StringBuilder builder = new StringBuilder();
		for (int index = 0; index < 5; index++) {
			final char rank = cards.charAt(index * 2 + 1);
			int insert = 0;
			for (; insert < builder.length(); insert++) {
				if (RANK_LIST.indexOf(builder.charAt(insert)) > RANK_LIST.indexOf(rank)) {
					break;
				}
			}
			builder.insert(insert, rank);
		}
		return builder.toString();
	}
	private static boolean isStraight(String rankList) {
		return RANK_LIST.indexOf(rankList) >= 0;
	}
	private static boolean isRoyal(String rankList) {
		return rankList.equals("ATJQK");
	}

	private static Integer[] countSameNumber(String rankList) {
		Map<Character, Integer> map = new HashMap<Character, Integer>();
		for (int index = 0; index < rankList.length(); index++) {
			char c = rankList.charAt(index);
			Integer integer = map.get(c);
			if (integer == null) {
				integer = 1;
				map.put(c, integer);
			} else {
				map.put(c, integer + 1);
			}
		}
		List<Integer> result = new ArrayList<Integer>(map.values());
		Collections.sort(result, Collections.reverseOrder());
		return result.toArray(new Integer[0]);
	}


	public static void main(String[] args) {
		System.out.println(getPokerRole("SQSJSASKST"));
		System.out.println(getPokerRole("D9D7D6D5D8"));
		System.out.println(getPokerRole("C2D2S2H3H2"));
		System.out.println(getPokerRole("C2D3S2H3H2"));
		System.out.println(getPokerRole("S9S4S8STSJ"));
		System.out.println(getPokerRole("C4H7D5S6H3"));
		System.out.println(getPokerRole("S6H6C5DQC6"));
		System.out.println(getPokerRole("S6HQC5DQC6"));
		System.out.println(getPokerRole("S6H4C5DQC6"));
		System.out.println(getPokerRole("SJSQSKSAC2"));
	}
}
