Let's Go to the Movies#1631

Let's Go to the Movies

1 second
64 megabytes
Hard

A favorite pastime for big families in Acmestan is going to the movies. It is quite common to see multi-generation families going together to watch a movie. Movie theaters in Acmestan have two types of tickets: a single ticket for exactly one person, and a family ticket, which allows a parent and their children to enter the theater. Needless to say, a family ticket is always priced higher than a single ticket and can cost up to five times as much.

It can be quite challenging for families to decide which ticket arrangement is the most economical. For example, the family shown in the illustration has four possible ticket arrangements: seven single tickets; two family tickets; one family ticket (for adam, bob, cindy) and four single tickets for the remainder; or one family ticket (for bob and his four children) with two single tickets for the remaining members.

Write a program to determine the ticket arrangement that has the lowest total price. If there is more than one such arrangement, choose the one with fewer tickets.

Input

Your program will be tested on one or more test cases. The first line of each test case contains two positive integers and , where is the price of a single ticket and is the price of a family ticket. The following lines of the test case are either the name of a person going alone or are of the form:

N_1 N_2 N_3 N_k

where N_1 is the name of a parent, and N_2, \ldots, N_k are his or her children. Names are composed only of lowercase letters and are no longer than characters. No parent will take more than children to the movies. Names are unique, and a particular person's name can appear at most twice: once as a parent, and once as a child. There will be at least one person and at most people in any test case.

The end of a test case is indicated by the beginning of the next test case (a line with two integers). The end of the last test case is indicated by a line with two zeros.

Output

For each test case, output the result in the following format:

.

where is the test case number (starting from ), is the number of single tickets, is the number of family tickets, and is the total ticket price.

Examples

Example 1

Loading
Loading