The cultivation of UESTC master's students adopts a combination of coursework and thesis research. Through coursework and thesis research, students systematically master the theoretical knowledge in their discipline and develop problem-solving abilities.
The total credits for a master's degree are divided into two parts: course credits and compulsory sessions. Courses in course credits are divided into two categories: degree courses and non-degree courses. Degree courses include public foundational courses and professional foundational courses. Non-degree courses include professional elective courses, interdisciplinary elective courses, and other elective courses.
To complete the program, students must meet the following credit requirements:
Now, given a course selection plan, including the course names, course types, and credits for each course, please determine if the plan meets the credit requirements.
The first line contains an integer $$$T$$$ ($$$1 \le T \le 100$$$), indicating the number of test cases.
The first line of each test case contains seven integers $$$a,b,c,d,e,f,g$$$ ($$$1 \leq a,b,c,d,e,f,g \leq 100$$$, $$$a \geq b+c$$$, $$$b \geq d \gt f$$$, $$$b \geq e \geq f+g$$$), the meanings of which are described above.
The second line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 100$$$), indicating the number of selected courses.
The following $$$3n$$$ lines describe the $$$n$$$ courses, with each course occupying three lines. The first line contains the course name with a maximum length of $$$50$$$, consisting of only English letters and spaces. All the course names are different from others, and spaces will not appear at the beginning and the end of the names. The second line contains the course type, which is one of public foundational courses, professional foundational courses, professional elective courses, interdisciplinary elective courses, other elective courses, and compulsory sessions. The third line contains an integer representing the course credit, ranging within $$$[1,10]$$$.
For each test case, output $$$\texttt{YES}$$$ in a single line if the plan meets the credit requirements, otherwise output $$$\texttt{NO}$$$ in a single line.
1 28 24 4 15 15 6 7 15 Socialism with Chinese Characteristics public foundational courses 2 Matrix Theory professional foundational courses 3 Optimization Theory professional foundational courses 3 Communication Network Theory professional elective courses 2 Bayesian Learning and Random Matrix professional elective courses 2 Image and Video Processing professional foundational courses 2 Graph Theory professional foundational courses 3 Machine Learning professional elective courses 2 Visual Data Analysis professional elective courses 2 Guidance on Writing Graduate Thesis other elective courses 1 Graduate English public foundational courses 3 Teaching Practice compulsory sessions 1 Academic Activities compulsory sessions 1 General Education Elective Courses compulsory sessions 1 Academic Exchange compulsory sessions 1
YES
| Name |
|---|


