Problem C

Statement
Copy Copied
# **C. Meximum Array 2**

**Time limit:** 2 seconds
**Memory limit:** 256 megabytes

You are given three integers **n**, **k**, and **q**.
You are also given **q** tuples **(c, l, r)** where

* 1 ≤ c ≤ 2
* 1 ≤ l ≤ r ≤ n

An array **a₁, a₂, …, aₙ** is **meximum** if:

* For every tuple (c, l, r):

  * If **c = 1**, then
    **min(a[l], a[l+1], …, a[r]) = k**
  * If **c = 2**, then
    **MEX(a[l], a[l+1], …, a[r]) = k**

Here, **MEX** means the smallest non-negative integer not present in the segment.

The parameter **k** is the same for all constraints.

You must construct **any valid meximum array** `a₁ … aₙ` of length n.
It is guaranteed that at least one valid array exists.

The values must satisfy
**0 ≤ aᵢ ≤ 10⁹**.

If multiple answers exist, output any.

---

# **Input**

Each test contains multiple test cases.

* First line: **t** (1 ≤ t ≤ 500)

For each test case:

* A line containing **n, k, q**
  (1 ≤ k ≤ n ≤ 100; 1 ≤ q ≤ 100)
* Then q lines follow, each containing a tuple
  **c l r**

There are no constraints on the sum of n or q across test cases.

---

# **Output**

For each test case, print one line containing a valid meximum array of length n.

---

# **Example**

**Input**

```
4
6 2 2
1 1 3
2 2 6
3 3 1
2 1 3
3 3 2
1 1 1
1 3 3
3 2 2
2 1 2
2 2 3
```

**Output**

```
2 5 4 3 0 1
2 0 1
3 3 3
1 0 1
```

---

# **Notes**

* In test 1:

  * (1, 1, 3) → min(a₁,a₂,a₃)=2
  * (2, 2, 6) → MEX(a₂…a₆)=2
    One valid array is `[2,5,4,3,0,1]`.

* In test 2:

  * (2, 1, 3) → MEX=3
    One valid array is `[2,0,1]`.