P28467 [洛谷] [COCI2009-2010#3] PLANETE
提高
题目描述

Problem Description

Translated from COCI 2009.12 T6 "PLANETE"

Given \( N \) records, each record \( i \) contains two yearless dates \( A_i \), \( B_i \) (in other words, only month and day) and an array of length \( M \) denoted as \( a_{i,1}, a_{i,2}, \ldots, a_{i,M} \).

Please provide any set of solutions for the system of equations regarding \( x_1, x_2, \ldots, x_N \):

If there is no solution, output \(\texttt{-1}\).

Input Format

The first line contains two integers \( N, M \).
The next \( N \) lines, each starts with four integers representing the day of \( A_i \), the month of \( A_i \), the day of \( B_i \), and the month of \( B_i \). Following these are \( M \) integers representing \( a_{i,1}, a_{i,2}, \ldots, a_{i,M} \).
It is guaranteed that the input months and days are valid.

Output Format

If there is a solution, output \( M \) lines, each containing an integer representing \( x_i \).
If there is no solution, output \(\texttt{-1}\).

Sample Input and Output

Sample Input #1

1 1
26 02 03 03 1

Sample Output #1

5

Sample Input #2

1 1
26 02 03 03 2

Sample Output #2

185

Sample Input #3

3 3
22 03 01 10 9 10 10
05 05 16 12 1 7 10
20 06 15 01 4 9 10

Sample Output #3

102
204
125

Notes/Hints

\( 1 \le N, M \le 200 \), \( 0 \le a_{i,j} \le 200 \), it is guaranteed that the input months and days are valid.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1 26 02 03 03 1
样例输出
5