WIDGET - Widget Factory

题意翻译

### 题目描述 一个零件工厂生产$N$种零件,第$i$种零件的生产天数在$ 3$天到$9$天之间,且一定是一个整数。 有$M$条记录,每一条记录记录着某个工人的工作情况:开始工作在星期几、结束工作在星期几、在这段时间内共做了哪些零件。 假设工人在工作期间没有放假,开始工作当天和结束工作当天在工作,且零件刚好做完,试通过这$M$条记录得到每一种零件的生产天数。 ### 输入数据 有若干组输入数据。 每一组输入的第一行两个正整数$N\ M(1 \leq N,M \leq 300)$表示加工的数量和记录的数量。 接下来$2M$行每两行描述一条记录。 每一条记录的第一行一个正整数$k(1 \leq k \leq 10000)$和两个字符串$S\ T$,$S\ T$分别表示开始工作在星期几和结束工作在星期几,只有`SUN MON TUE WED THU FRI SAT`$7$种可能,$k$表示这段时间内工人加工的零件数量; 第二行$k$个正整数$a_i$表示加工的零件的种类,可能存在某些$a_i$相等。 比如某一条记录中工人在星期三开始工作,星期六结束工作,加工了$4$个零件,分别是$13\ 18\ 1\ 13$,那么对于这一条记录的输入格式就是 ``` 4 TUE SUN 13 18 1 13 ``` 当$N=M=0$时表示输入结束 ### 输出格式 对于每一组数据输出一行。如果存在唯一解输出$N$个正整数,第$i$个正整数表示第$i$个零件的加工时间,**注意输出时第一个数之前和最后一个数之后不能有空格,而两个数之间严格有一个空格**;如果存在多解输出`Multiple solutions.`;如果无解输出`Inconsistent data.`。

题目描述

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 diofferent 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, built 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 these records (if possible) the number of days that are required to build the different types of widgets.

输入输出格式

输入格式


The input contains several blocks of test cases. Each case begins with a line containing two integers: the number 1 <= n <= 300 of the different types, and the number 1 <= m <= 300 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 1 <= k <= 10000 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 bythe strings 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT' and 'SUN'. The second line contains k integers separated by spaces. These numbers are between 1 and n , and they describe the diofferent 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 'Inconsistent data.'(without the quotes).

输入输出样例

输入样例 #1

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

输出样例 #1

8 3
Inconsistent data.