hy9360 tried to solve DOJ problems in problem-number order, and discovered that problem numbers are unrelated to difficulty order.
Each problem difficulty is represented by a pair consisting of a tier name and a tier number. From easiest to hardest, the tier names are
Bronze,Silver,Gold,Platinum,Diamond,Ruby.
Within the same tier name, a larger number means an easier problem: is the easiest and is the hardest. For example, Bronze is easier than Bronze , and Gold is easier than Platinum .
You are given problems and a threshold difficulty . Print the problem numbers of all problems whose difficulty is at most , meaning that they are not harder than , in increasing order of difficulty.
Problems with exactly the same difficulty may be printed in any order.
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
is the threshold difficulty.
For the -th problem, denote its problem number, problem name, tier name, and tier number, respectively.
Output
For each test case, print the problem numbers satisfying the condition, one by one, in increasing order of difficulty. Problems with exactly the same difficulty may be printed in any order.
If no problem satisfies the condition, print -1.
Constraints
- .
- .
- The sum of over all test cases does not exceed .
- Each of is one of
Bronze,Silver,Gold,Platinum,Diamond,Ruby(). - ().
- ().
- ().
- is a string of length from to consisting only of ASCII characters with codes from to ().
- The total length of all problem names over all test cases does not exceed .
Subtasks
Samples
In the first test case, the problems with difficulties Bronze , Bronze , Silver , and Silver satisfy the threshold.
In the second test case, no problem has difficulty at most Bronze .