In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest):

-  royal flush - ace, king, queen, jack and ten, all in the same suit

-  straight flush - five cards of the same suit in sequence, such
as 10,9,8,7,6 of clubs; ace can be counted both as the highest card or as the
lowest card - A,2,3,4,5 of hearts is a straight flush. But 4,3,2,A,K of hearts is not a straight flush - it's just a flush.

-  four of a kind - four cards of the same rank, such as four kings.

-  full house - three cards of one rank plus two cards of another rank

-  flush - five cards of the same suit (but not a straight flush)

-  straight - five cards in order - just like the straight flush, but mixed suits

-  three of a kind - three cards of one rank and two other cards

-  two pairs - two cards of one rank, two cards of another rank, and one more card

-  pair - two cards of the same rank

-  high card - none of the above

Write a program that will help you play poker by telling you what kind of hand you have.

-----Input-----

The first line of input contains the number of test cases (no more than 20). Each test case consists of one line - five space separated cards. Each card is represented by a two-letter (or digit) word. The first character is the rank (A,K,Q,J,T,9,8,7,6,5,4,3 or 2), the second character is the suit (S,H,D,C standing for spades, hearts, diamonds and clubs). The cards can be in any order (but they will not repeat).

-----Output-----

For each test case output one line describing the type of a hand, exactly like in the list above.

-----Example-----
Input:
3
AH KH QH TH JH
KH 5S 3C 5C 7D
QH QD 2S QC 2C

Output:
royal flush
pair
full house

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
cards = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']

def royal_flush(arr):
	nonlocal ans, confirm
	rf_set = 'TJQKA'
	rf = 1
	for char in arr:
		if char[0] not in rf_set:
			rf = 0
			break
	if rf:
		if len(set(suit)) == 1:
			ans = 'royal flush'
			confirm = 1

def straight_flush(arr):
	nonlocal ans, confirm
	sf = 1
	for i in range(1, 5):
		if arr[i] - arr[i - 1] != 1:
			sf = 0
			break
	if sf:
		if len(set(suit)) == 1:
			ans = 'straight flush'
			confirm = 1
		else:
			ans = 'straight'
			confirm = 1

def four(arr):
	nonlocal ans, confirm
	f = 0
	for char in arr:
		if arr.count(char) == 4:
			f = 1
			break
	if f:
		confirm = 1
		ans = 'four of a kind'

def full_house(arr):
	nonlocal ans, confirm
	fh = 0
	three = 0
	two = 0
	for char in arr:
		if arr.count(char) == 3:
			three = 1
		elif arr.count(char) == 2:
			two = 1
	if three and two:
		confirm = 1
		ans = 'full house'
	elif three:
		confirm = 1
		ans = 'three of a kind'

def two_pairs(arr):
	nonlocal ans, confirm
	temp = []
	for char in arr:
		if arr.count(char) == 2:
			if char not in temp:
				temp.append(char)
	if len(temp) == 2:
		confirm = 1
		ans = 'two pairs'
	elif len(temp) == 1:
		confirm = 1
		ans = 'pair'

def idex(char_x):
	return cards.index(char_x)
for _ in range(int(input())):
	onhand = list(input().split())
	cards_set = [[], []]
	suit = []
	confirm = 0
	ans = ''
	for c in onhand:
		num = idex(c[0])
		cards_set[0].append(num)
		if num == 0:
			cards_set[1].append(13)
		else:
			cards_set[1].append(num)
		suit.append(c[1])
	royal_flush(onhand)
	if not confirm:
		cards_set[0] = sorted(cards_set[0])
		cards_set[1] = sorted(cards_set[1])
		straight_flush(cards_set[0])
		straight_flush(cards_set[1])
	if not confirm:
		four(cards_set[0])
		four(cards_set[1])
	if not confirm:
		full_house(cards_set[0])
		full_house(cards_set[1])
	if not confirm:
		if len(set(suit)) == 1:
			confirm = 1
			ans = 'flush'
	if not confirm:
		two_pairs(cards_set[0])
		two_pairs(cards_set[1])
	print(ans if confirm else 'high card')