Time limit: 0.4s
Memory limit: 256MB
Input:
Output:
Your task is to determine one possible binary array of length that abides by given constraints of the form:
– the -th smallest element in subarray is .
Please note that array is 0-indexed.
Input
The first line of input contains two integers and
() – the length of array and the number of constraints.
The next lines describe the constraints.
Each line contains four integers , describing the -th constraint.
Output
The first line of the output contains integers - one possible binary array .
If there are several that abide by all constraints you may output any of them.
If there is no such array, you must instead output the single integer .
Subtasks
Subtask | Constraints | Points |
---|---|---|
(1) | , | |
(2) | , , for all constraints | |
(3) | , , for all constraints or | |
(4) | , |
Example
stdin
4 5
0 1 2 1
0 2 2 0
2 2 1 0
0 1 1 0
1 2 1 0
stdout
0 1 0 0
Explanation
There are several binary arrays that abide by all the constraints. One of them is:
0 1 0 0
Because:
- The 2-nd smallest element among
0 1
is1
. - The 2-nd smallest element among
0 1 0
is0
. - The 1-st smallest element among
0 1 0 0
is0
. - The 1-st smallest element among
0 1
is0
. - The 1-st smallest element among
1 0
is0
.