P17587 [CodeChef] C00K0FF
普及-
题目描述

Read problems statements in mandarin chinese, russian and vietnamese as well.

Chef wants to prepare a Cook-Off contest with 5 problems chosen from a set of N problems. He has marked the difficulty of each problem within a range identified by one of the following strings: "cakewalk", "simple", "easy", "easy-medium", "medium", "medium-hard", "hard". According to this page, a Cook-Off contest must have problems of the following difficulties:

exactly one "cakewalk";
exactly one "simple";
exactly one "easy";
one "easy-medium" or one "medium";
one "medium-hard" or one "hard".

Given the information about the N problems, can you advise Chef if it's possible to pick 5 problems and form a valid Cook-Off contest?

Input ------

The first line of input contains one integer T denoting the number of test cases.
T test cases follow.
The first line of each test case contains a single integer N.
Then N lines follow; the i-th line contains a single string s_{i}, denoting the difficulty of the i-th problem.

Output ------

For each test case, output "Yes" if it's possible to pick 5 problems and form a valid Cook-Off contest; otherwise, output "No".

Constraints ------

$1 ≤ T ≤ 100000$
$5 ≤ N ≤ 100000$
$sum of N in all test cases ≤ 600000$
$s_{i} can only be one of the following strings:

$"cakewalk"$
$"simple"$
$"easy"$
$"easy-medium"$
$"medium"$
$"medium-hard"$
$"hard"$$

Subtask #1 (11 points):

$N = 5$

Subtask #2 (27 points):

$5 ≤ N ≤ 15$
$T ≤ 100$

Subtask #3 (62 points):

$original constraints$

----- Sample Input 1 ------
3
5
easy
medium
medium-hard
simple
cakewalk
7
simple
simple
medium
medium
easy-medium
cakewalk
easy
7
cakewalk
simple
easy
easy-medium
medium
medium-hard
hard
----- Sample Output 1 ------
Yes
No
Yes
----- explanation 1 ------

Example case 2: There are neither problems of "medium-hard" level nor "hard" level, so it's impossible to form a Cook-Off contest.
输入格式

见题面

输出格式

见题面

样例输入
3 5 easy medium medium-hard simple cakewalk 7 simple simple medium medium easy-medium cakewalk easy 7 cakewalk simple easy easy-medium medium medium-hard hard
样例输出
Yes No Yes