← Home
write a go solution for Description:
You are asked to build an array a, consisting of n integers, each element should be from 1 to k.

The array should be non-decreasing (a_i<=a_i+1 for all i from 1 to n-1).

You are also given additional constraints on it. Each constraint is of one of three following types:

- 1~i~x: a_i should not be equal to x;
- 2~i~j~x: a_i+a_j should be less than or equal to x;
- 3~i~j~x: a_i+a_j should be greater than or equal to x.

Build any non-decreasing array that satisfies all constraints or report that no such array exists.

Input Format:
The first line contains a single integer t (1<=t<=10^4) — the number of testcases.

The first line of each testcase contains three integers n,m and k (2<=n<=2*10^4; 0<=m<=2*10^4; 2<=k<=10).

The i-th of the next m lines contains a description of a constraint. Each constraint is of one of three following types:

- 1~i~x (1<=i<=n; 1<=x<=k): a_i should not be equal to x;
- 2~i~j~x (1<=i<j<=n; 2<=x<=2*k): a_i+a_j should be less than or equal to x;
- 3~i~j~x (1<=i<j<=n; 2<=x<=2*k): a_i+a_j should be greater than or equal to x.

The sum of n over all testcases doesn't exceed 2*10^4. The sum of m over all testcases doesn't exceed 2*10^4.

Output Format:
For each testcase, determine if there exists a non-decreasing array that satisfies all conditions. If there is no such array, then print -1. Otherwise, print any valid array — n integers from 1 to k.

Note:
None. Output only the code with no comments, explanation, or additional text.