A levels are just over and Mr. Panda is already thinking about his university admissions. Local university admissions are based on University Admission Scores (UAS), which ranges from 0 to 90, taking on only integral values.
The calculation for UAS is quite complicated due to the different combination of content subjects any student can take. There are H2 content subjects which are worth a maximum of 20 points each in the UAS and H1 content subjects that are worth a maximum of half the points of H2, 10 points.
Out of these subjects, all students must take H1 Project Work. They must also take either H1 General Paper or H2 Knowledge and Inquiry but not both. Apart from these, students that take General Paper also have the option to take up another additional 3 H2 and 1 H1 subject or 4 additional H2 subjects.
However, a Knowledge and Inquiry (KI) student cannot take up 4 additional H2 subjects but can instead opt for 3 additional H2 subjects only or 3 additional H2 subjects plus 1 H1 subject. Other than that, there are no more restrictions.
Yet, since a H2 subject is worth 20 points and a H1 subject is worth 10 points, some subject combination will lead to a total maximum UAS of 100. In this case, the worse performing H2 subject will be considered as a H1 subject, i.e. worth only 10 points.
For each H2 subject, different points are awarded for different grades that the student gets.
The grades will be converted to the points as per the table and accumulated to form the UAS. If the UAS isn't an integral value, then it would be the next highest integral value of the total points accumulated via the table.
Mr. Panda has predicted that his UAS will be between L and H inclusive. He has also made several predictions about his A level grades based on his past exam results. Given this predictions, can you help Mr. Panda figure out all his possible set of grades?
The first line of input will contain a two integers 0 ≤ L ≤ H ≤ 90 separated by a space. The next several lines of input will contain subject grade predictions according to the input format as in the sample, each subject is at most 50 characters long. You may assume that all subjects stated are actual subjects, the level will only be either H1 or H2 and the grade will be A,B,C,D,E,S or U. You can also assume that there will be at least 1 subject combination that contains all the predicted subjects, though the grades may not give the required UAS.
For every possible set of grades, print the H2 grades from best to worst, followed by a '/', then the H1 grades from best to worst. The same set of grades for different subjects are considered the same set. Sort the output in descending order of number of H2 subjects then in descending order of number of H1 subjects then in descending order of UAS. In the case of a tie, sort in descending order of best H2 grade, second best H2 grade and so on and if there is a need to in descending order of best H1 grade, second best H1 grade and so on. If there is no possible combination, print "FAIL" on one line.
Subtask 1 (20%): L=0 and H=90
Subtask 2 (20%): There will be no subject grade predictions
Subtask 3 (60%): No restrictions
Subtask 4 (0%): Sample test case
H2 Mathematics B
H1 Economics B