题目描述
Problem Description
The APIO kingdom is under attack by ninjas! Ninjas are highly skilled, as they can hide in the shadows, making themselves invisible to others. The entire kingdom, except for the APIO castle where the king resides, has been occupied. In front of the castle, there are N bushes, numbered from 1 to N, and exactly K ninjas are hiding behind K of these bushes. Inside the castle, there are M guards. Guard i monitors a continuous range of bushes from Ai to Bi. Each guard reports to the king whether they have seen any ninjas within their monitored range. As the king's servant, you need to inform the king which bushes definitely have a ninja behind them, based on the guards' reports. That is, for any ninja arrangement that is consistent with the guards' reports, there is a ninja behind this bush.
You need to write a program to output the numbers of all such bushes.
Input Format
The first line contains three space-separated integers N, K, and M. N is the number of bushes, K is the number of ninjas, and M is the number of guards.
The next M lines describe the information for each guard. The i-th line contains three integers Ai, Bi, and Ci, indicating that guard i monitors the range from Ai to Bi (Ai ≤ Bi). Ci is either 0 or 1, where 0 means no ninja was seen in the range, and 1 means at least one ninja was seen in the range.
The input data guarantees that there is at least one ninja arrangement that satisfies all conditions.
Output Format
If there are bushes where a ninja is definitely hiding, output these bushes in ascending order of their numbers, one per line. If there are X such bushes, output X lines. If no such bushes exist, output a single line containing "-1".
Sample Input and Output
Sample Input #1
5 3 4
1 2 1
3 4 1
4 4 0
4 5 1
Sample Output #1
3
5
Sample Input #2
5 1 1
1 5 1
Sample Output #2
-1
Notes
Sample Explanation 1
In this example, there are two possible arrangements: 1, 3, 5 or 2, 3, 5. This means that bushes 3 and 5 definitely have a ninja behind them. Considering the first bush, there is an arrangement where a ninja is behind it, but also an arrangement where there is no ninja, so it should not be output. Similarly, bush 2 should not be output.
Sample Explanation 2
In this example, there are no bushes where a ninja is definitely hiding.
- The number of bushes 1 ≤ N ≤ 100,000.
- The number of ninjas 1 ≤ K ≤ N.
- The number of guards 0 ≤ M < 100,000.
For 10% of the data, N ≤ 20, M ≤ 100.
For 50% of the data, N ≤ 1,000, M ≤ 1,000.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分