|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
The widget factory produces several different kinds of widgets. Each widget is carefully built by a skilled widgeteer. The time required to build a widget depends on its type: the simple widgets need only 3 days, but the most complex ones may need as many as 9 days.
The factory is currently in a state of complete chaos: recently, the factory has been bought by a new owner, and the new director has fired almost everyone. The new staff know almost nothing about building widgets, and it seems that no one remembers how many days are required to build each different type of widget. This is very embarrassing when a client orders widgets and the factory cannot tell the client how many days are needed to produce the required goods. Fortunately, there are records that say for each widgeteer the date when he started working at the factory, the date when he was fired and what types of widgets he built. The problem is that the record does not say the exact date of starting and leaving the job, only the day of the week. Nevertheless, even this information might be helpful in certain cases: for example, if a widgeteer started working on a Tuesday, build a Type 41 widget, and was fired on a Friday, then we know that it takes 4 days to build a Type 41 widget. Your task is to figure out from those records (if possible) the number of days that are required to build the differnt types of widgets.
The input contains several blocks of test cases. Each case begins with a line containing two integers: the number n (1 ≤ n ≤ 100) of the different types, and the number m (1 ≤ m ≤ 100) of the records. This line is followed by a description of the m records. Each record is described by two lines. The first line contains the total number k (1 ≤ k ≤ 400) of widgets built by this widgeteer, followed by the day of week when he/she started working and the day of the week he/she was fired. The days of the week are given by the strings ‘
SAT’ and ‘
SUN’. The second line contains k integers separated by spaces. These numbers are between 1 and n, and they describe the different types of widgets that the widgeteer built. For example, the following two lines mean that the widgeteer started working on a Wednesday, built a Type 13 widget, a Type 18 widget, a Type 1 widget, again a Type 13 widget, and was fired on a Sunday.
4 WED SUN 13 18 1 13
Note that the widgeteers work 7 days a week, and they were working on every day between their first and last day at the factory (if you like weekends and holidays, then do not become a widgeteer!).
The input is terminated by a test case with n = m = 0.
For each test case, you have to output a single line containing n integers separated by spaces: the number of days required to build the different types of widgets. There should be no space before the first number or after the last number, and there should be exactly one space between two numbers. If there is more than one possible solution for the problem, then write ‘
Multiple solutions.’ (without the quotes). If you are sure that there is no solution consistent with the input, then write ‘Inconsi
stent data.’ (without the quotes).
2 3 2 MON THU 1 2 3 MON FRI 1 1 2 3 MON SUN 1 2 2 10 2 1 MON TUE 3 1 MON WED 3 0 0
8 3 Inconsistent data.