Restore Array

Time limit: 0.4s Memory limit: 256MB Input: Output:

Your task is to determine one possible binary array AA of length NN that abides by MM given constraints of the form:
(l,r,k,value)(l, r, k, value) – the kk-th smallest element in subarray A[l..r]A[l..r] is valuevalue (0lr<N,1krl+1,0value1)(0 ≤ l ≤ r < N, 1 ≤ k ≤ r - l + 1, 0 ≤ value ≤ 1).
Please note that array AA is 0-indexed.

Input

The first line of input contains two integers NN and MM
(1N5 000,1M10 0001 ≤ N ≤ 5\ 000, 1 ≤ M ≤ 10\ 000) – the length of array AA and the number of constraints.

The next MM lines describe the constraints.
Each line contains four integers li,ri,ki,valueil_i, r_i, k_i, value_i, describing the ii-th constraint.

Output

The first line of the output contains NN integers - one possible binary array AA.
If there are several that abide by all MM constraints you may output any of them.
If there is no such array, you must instead output the single integer 1-1.

Subtasks

Subtask Constraints Points
(1) 1N181 ≤ N ≤ 18, 1M2001 ≤ M ≤ 200 77
(2) 1N5 0001 ≤ N ≤ 5\ 000, 1M10 0001 ≤ M ≤ 10\ 000, for all constraints k=1k = 1 1313
(3) 1N5 0001 ≤ N ≤ 5\ 000, 1M10 0001 ≤ M ≤ 10\ 000, for all constraints k=1k = 1 or k=(rl+1)k = (r - l + 1) 2525
(4) 1N5 0001 ≤ N ≤ 5\ 000, 1M10 0001 ≤ M ≤ 10\ 000 5555

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:

  1. The 2-nd smallest element among 0 1 is 1.
  2. The 2-nd smallest element among 0 1 0 is 0.
  3. The 1-st smallest element among 0 1 0 0 is 0.
  4. The 1-st smallest element among 0 1 is 0.
  5. The 1-st smallest element among 1 0 is 0.

Log in or sign up to be able to send submissions!