PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000090. Quá nhiều đoạn – bản khó (Too Many Segments (hard version))

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Quá nhiều đoạn – bản khó (Too Many Segments (hard version))

Too Many Segments (hard version)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You have nn inclusive integer intervals [li,ri][l_i,r_i] indexed from 11 to nn. An integer coordinate is overloaded if more than kk retained intervals cover it. Remove the minimum number of intervals so that no integer point is overloaded, outputting the count and indices removed. Intervals may overlap or coincide.

Input

The first line contains n,kn,k. Each of the next nn lines contains li,ril_i,r_i.

Output

Print the minimum number mm of removed intervals and then mm distinct one-based indices in any order. The second line may be empty if m=0m=0.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤201\le k\le n\le20; 1≤li≤ri≤2⋅1051\le l_i\le r_i\le2\cdot10^5.
  • Subtask 2 (30 points): 1≤k≤n≤20001\le k\le n\le2000; 1≤li≤ri≤2⋅1051\le l_i\le r_i\le2\cdot10^5.
  • Subtask 3 (50 points): 1≤k≤n≤2⋅1051\le k\le n\le2\cdot10^5; 1≤li≤ri≤2⋅1051\le l_i\le r_i\le2\cdot10^5.

Examples

Input

5 1
1 3
3 5
4 6
7 8
2 4

Output

2
5 2

Explanation

With k=1k=1, keep intervals [1,3][1,3], [4,6][4,6], and [7,8][7,8], removing intervals 22 and 55. The retained intervals are pairwise disjoint at all integer points. At least two removals are necessary because three of the original intervals mutually intersect.