| Soy Cup #1: Firefly |
|---|
| Finished |
Bidding is the first phase of a bridge game where players communicate their hand strength and distribution to determine the contract (the final goal for the round). The rules of bidding are listed as follows.
You're given a bidding sequence. Determine if it is both valid (follows all rules) and complete (meets an ending condition).
Each test contains multiple tests. The first line contains one integer $$$t$$$ ($$$1\le t\le 100$$$) — the number of test cases. The description of each test case follows.
The first line of each test case contains one integer $$$n$$$ ($$$1\le n\le 320$$$) — the length of the bidding sequence.
The second line contains $$$n$$$ strings which indicate each player's bids. It is guaranteed that the bids are valid.
For each test case, if the bidding sequence is valid, output "YES"; otherwise, output "NO". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
64P P P P5P P P P X5P 1C P P P6P P 1C 1D P P8P 1H X XX X P P P121S P 2C P 2D P 4S X XX P P P
YES NO YES NO NO YES
| Name |
|---|


