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

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "cards = ['A','2','3','4','5','6','7','8','9','T','J','Q','K']\n\ndef royal_flush(arr):\n nonlocal ans, confirm\n rf_set = 'TJQKA'\n rf = 1\n for char in arr:\n  if char[0] not in rf_set:\n   rf = 0\n   break\n if rf :\n  if len(set(suit)) == 1:\n   ans = 'royal flush'\n   confirm = 1\ndef straight_flush(arr):  # and 'straight'\n nonlocal ans,confirm\n sf = 1\n for i in range(1,5):\n  if arr[i] - arr[i-1] != 1:\n   sf = 0\n   break\n if sf:\n  if len(set(suit)) == 1 :\n   ans = 'straight flush'\n   confirm = 1\n  else:\n   ans = 'straight'\n   confirm = 1\ndef four(arr):\n nonlocal ans, confirm\n f = 0\n for char in arr:\n  if arr.count(char) == 4:\n   f = 1\n   break\n if f:\n  confirm = 1\n  ans = 'four of a kind'\ndef full_house(arr): # and three\n nonlocal ans, confirm\n fh = 0\n three = 0\n two = 0\n for char in arr:\n  if arr.count(char) == 3:\n   three = 1\n  elif arr.count(char) == 2:\n   two = 1\n if three and two:\n  confirm = 1\n  ans = 'full house'\n elif three:\n  confirm = 1\n  ans = 'three of a kind'\ndef two_pairs(arr):\n nonlocal ans, confirm\n temp = []\n for char in arr:\n  if arr.count(char) == 2:\n   if char not in temp:\n    temp.append(char)\n if len(temp) == 2:\n  confirm = 1\n  ans = 'two pairs'\n elif len(temp) == 1:\n  confirm = 1\n  ans = 'pair'\n\ndef idex(char_x):\n return cards.index(char_x)\nfor _ in range(int(input())):\n onhand = list(input().split())\n cards_set = [[],[]]\n suit = []\n confirm = 0\n ans = ''\n for c in onhand:\n  num = idex(c[0])\n  cards_set[0].append(num)\n  if num == 0:\n   cards_set[1].append(13)\n  else:\n   cards_set[1].append(num)\n  suit.append(c[1])\n royal_flush(onhand)\n if not confirm:\n  cards_set[0] = sorted(cards_set[0])\n  cards_set[1] = sorted(cards_set[1])\n  straight_flush(cards_set[0])\n  straight_flush(cards_set[1])\n if not confirm:\n  four(cards_set[0])\n  four(cards_set[1])\n if not confirm:\n  full_house(cards_set[0])\n  full_house(cards_set[1])\n if not confirm:\n  if len(set(suit)) == 1:\n   confirm = 1\n   ans = 'flush'\n if not confirm:\n  two_pairs(cards_set[0])\n  two_pairs(cards_set[1])\n print(ans if confirm else 'high card')"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: