409947: GYM103861 E Prof. Pang and Poker

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Prof. Pang and Pokertime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Prof. Pang is playing a card game with his two friends Alice and Bob. All cards are drawn from a standard 52-card deck. A standard 52-card deck comprises $$$13$$$ ranks in each of the four French suits: clubs ($$$\clubsuit$$$), diamonds ($$$\diamondsuit$$$), hearts ($$$\heartsuit$$$) and spades ($$$\spadesuit$$$). Each suit includes an Ace (A), a King (K), a Queen (Q), and a Jack (J), each depicted alongside a symbol of its suit; and numerals or pip cards from the Deuce (Two) to the Ten, with each card depicting that many symbols (pips) of its suit. No card can be drawn more than once.

Individual cards are ranked as follows (high-to-low): A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2. Suits do not affect ranks of the cards. For example, Ace of diamonds and Ace of clubs have the same rank. No one of them is ranked strictly higher than the other.

Initially, Alice and Bob will hold one or more cards while Prof. Pang will hold exactly one card. Each player can see cards held by himself/herself and cards held by other players. They will play the game in the following multi-round rule:

  • The initiative player chooses one card and put it out to start one round.
  • The next player can pass or put out a new card, then the player after the next can also pass or put out a new card, and so on. The only constraint is that the rank of the newly put card should be strictly higher than all previous cards in this round.
  • The round ends when two players choose to pass consecutively. The one who put out the last card becomes the initiative player in the next round.
  • If someone put out all the cards in his/her hand, the game ends immediately.

In this game, Alice is the initiative player in the first round. Bob, Prof. Pang, and Alice are the next players of Alice, Bob, and Prof. Pang respectively. Prof. Pang will be happy if and only if he is the one that first put out all the cards. (Prof. Pang wants to be happy, of course.) Alice wants to drink milk tea so she decides to make Prof. Pang happy and then asks him to buy milk tea for her. However, Bob doesn't want it to happen, so he decides to avoid Prof. Pang from being happy. If they play the game optimally for themselves, will Prof. Pang be happy in the end?

Input

The first line contains a single integer $$$T$$$ ($$$1\le T \le 10^4$$$) denoting the number of test cases. For each test case:

The first line contains two integers $$$n,m$$$ ($$$1\le n,m \le 50$$$) denoting the number of cards in Alice's hand and Bob's hand initially.

The second line contains $$$n$$$ strings $$$a_i$$$ ($$$1\le i \le n$$$) denoting the cards in Alice's hand.

The third line contains $$$m$$$ strings $$$b_i$$$ ($$$1\le i \le m$$$) denoting the cards in Bod's hand.

The fourth line contains one string $$$p$$$ denoting the card in Prof. Pang's hand.

For each card, the first character of its corresponding string denotes its rank. (Possible ranks are '2' ,'3','4','5','6','7','8','9','T','J','Q','K','A'. 'T' denotes $$$10$$$.) The second character denotes its suit. 'C' denotes clubs. 'D' denotes diamonds. 'H' denotes hearts. 'S' denotes spades.

It is guaranteed that each card appears at most once in one test case.

Output

For each test case, print one line. Print "Pang" if Prof. Pang will be happy. Otherwise, print "Shou".

ExampleInput
2
2 2
2H 2D
3H 3D
4S
2 2
2H 2D
3H 4D
4S
Output
Pang
Shou
Note
  • For the first case, Prof. Pang can always put out his only card "4S".
  • For the second case, Bob can put out "4D" and become the initiative player in the second round regardless of the card Alice put out in the first round, then Bob put out "3H" and the game ends.

加入题单

算法标签: