Problem: The only difference between easy and hard versions is constraints.

You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i.

The integer point is called bad if it is covered by strictly more than k segments.

Your task is to remove the minimum number of segments so that there are no bad points at all.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5) — the number of segments and the maximum number of segments by which each integer point can be covered.

The next n lines contain segments. The i-th line contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ 2 ⋅ 10^5) — the endpoints of the i-th segment.

Output

In the first line print one integer m (0 ≤ m ≤ n) — the minimum number of segments you need to remove so that there are no bad points.

In the second line print m distinct integers p_1, p_2, ..., p_m (1 ≤ p_i ≤ n) — indices of segments you remove in any order. If there are multiple answers, you can print any of them.

Examples

Input


7 2
11 11
9 11
7 8
8 9
7 8
9 11
7 9


Output


3
4 6 7 


Input


5 1
29 30
30 30
29 29
28 30
30 30


Output


3
1 4 5 


Input


6 1
2 3
3 3
2 3
2 2
2 3
2 3


Output


4
1 3 5 6 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct UF {
  vector<int> e;
  UF(int n) : e(n, -1) {}
  bool same_set(int a, int b) { return find(a) == find(b); }
  int size(int x) { return -e[find(x)]; }
  int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
  void join(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    if (e[a] > e[b]) swap(a, b);
    e[a] += e[b];
    e[b] = a;
  }
};
long long int p = 1000000007;
long long int power(long long int a, long long int b) {
  if (!b) return 1;
  long long int ans = power(a, b / 2);
  ans = (ans * ans) % p;
  if (b % 2) ans = (ans * a) % p;
  return ans;
}
bool compare(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first < b.first)
    return true;
  else if (a.first.first == b.first.first) {
    if (a.first.second > b.first.second)
      return true;
    else
      return false;
  } else
    return false;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int n, k;
  cin >> n >> k;
  vector<pair<pair<int, int>, int>> temp;
  int a, b, c, d, e, f;
  for (int i = 0; i < (n); ++i) {
    cin >> a >> b;
    temp.push_back({{a, b}, i});
  }
  sort(temp.begin(), temp.end());
  int dp[200009];
  memset(dp, 0, sizeof(dp));
  int i = 0, j = 0;
  vector<int> ans;
  multiset<pair<int, int>> temp1;
  while (i < n && j <= 200000) {
    if (j < temp[i].first.first) {
      dp[j] += dp[j - 1];
      j++;
    } else {
      dp[j] += dp[j - 1];
      while (temp[i].first.first == j) {
        if (dp[j] < k) {
          dp[j]++;
          dp[temp[i].first.second + 1]--;
          temp1.insert({-temp[i].first.second, temp[i].second});
          i++;
        } else {
          dp[temp[i].first.second + 1]--;
          auto it1 = temp1.begin();
          temp1.insert({-temp[i].first.second, temp[i].second});
          auto it = temp1.begin();
          ans.push_back((*it).second);
          b = (*it).first;
          dp[-b + 1]++;
          temp1.erase(it);
          i++;
        }
      }
      j++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (ans.size()); ++i) cout << ans[i] + 1 << " ";
}