|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||1||0||0||0.000%|
Indonesia tourism board has just sent a list of available room type of all hotels in Jakarta for teams that will participate in Indonesia Programming Contest 2008. Each record on the list contains:
To simplify the problem, let’s assume that each hotel will offer only one type of room (which means they will appear only once in the list).
Several participants have submitted their hotel preference to the committee, which consists of:
Based on the data above, write a program to find the cheapest hotel for each team. If there’re more than one cheapest hotels, then choose one with largest bed size. If there’re still more than one, then choose one which come first on the list.
You don’t have to worry about multiple teams assigned at one hotel. What we will do here is only make a suggestion for each team, not a reservation.
The first line of input contains an integer T, the number of test cases follow.
Each case will begin with two integers N (1 ≤ N ≤ 50) and M (1 ≤ M ≤ 50) the number of available hotel and the number of teams respectively. The next N lines each will contains four integers (bed size, room capacity, number of available room and the price per room) and a string which denotes the hotel’s name. The next M lines each will contains three data: bed size type (A, B or C), number of people in their teams and maximum number of person in a room.
Print "Case #X:" (X is the case number) at the first line of each test case. For each team, print on a single line the total cost and the hotel name which you suggested (in the same order as the team appearance in the input), separated by a single space. If there’re no hotels that match the team’s criteria, then output “no-hotel” (without quotes).
2 2 3 40 3 2 10 MyHotel 37 4 5 50 HisHotel B 5 3 A 3 4 B 7 2 4 2 30 2 5 10 IndigoHotel 35 2 5 10 PurpleHotel 36 2 5 10 GreenHotel 36 2 5 10 BrownHotel A 6 2 B 6 2
Case #1: 20 MyHotel no-hotel 200 HisHotel Case #2: 30 PurpleHotel 30 GreenHotel