//                              jai shree ram 3-i _/\_
#include<bits/stdc++.h>

#define mod 1000000007
#define pb push_back
#define lli long long int
#define ll long long
#define mk make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define plli pair<lli,lli>
#define mii map<int,int>
#define mlli map<lli,lli>
#define test lli chu;cin>>chu;while(chu--)
#define loop(i,n) for(lli i=0;i<n;i++)
#define lop(i,n) for(lli i=1;i<=n;i++)
#define pp  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define S(z) z.size()
#define tom set<lli>
#define fill(a,b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()

#define en cout<<"\n"
#define YES cout<<"YES"
#define NO  cout<<"NO"
#define Yes cout<<"Yes"
#define No  cout<<"No"
#define er  cout<<"-1"

#define tks(s) string s; cin>>s
#define tk1(n) lli n; cin>>n
#define tk2(n,k) tk1(n);tk1(k)
#define tk3(a,b,c) tk2(a,b);tk1(c)
#define tk4(a,b,c,d) tk3(a,b,c);tk1(d)
#define tttt vector<lli>

#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

using namespace std;
const long long INF64 = 1e18;
lli pow2(lli a,lli n,lli p)
{
    if(a == 0)
    return 0;
    if(n == 0)
    return 1;
    if(n%2 == 0)
    return (pow2(((a%p)*(a%p))%p,n/2,p)%p);
    else
    return ((pow2(((a%p)*(a%p))%p,n/2,p)%p)*(a%p))%p;
}

int main()
{
pp;
tk2(n,k);
mlli mp;
lli ct=0,i,j;
pair<plli,plli> p[n];
loop(i,n)
{
	tk2(x,y);
	p[i].fi.fi = y-x;
	p[i].fi.se = i;
	p[i].se.fi = x;
	p[i].se.se = y ;
}
sort(p,p+n);
vector<lli> v;
	for(i=0;i<n;i++)
	{
		lli x = p[i].se.fi;
		lli y = p[i].se.se;
		bool ok = false;
		for(j=x;j<=y;j++)
		{
			mp[j]++;
			if(mp[j]>k) ok =true;
		}
		if(ok)
		{
			v.pb(p[i].fi.se);
			for(j=x;j<=y;j++)
			mp[j]--;
//			if(mp[j]>k) ok =true;
		}

	}
	cout<<S(v)<<"\n";
	sort(all(v));
	loop(i,S(v)) cout<<v[i]+1<<" ";

return 0;
}


//                              jai shree ram 3-i _/\_
#include<bits/stdc++.h>

#define mod 1000000007
#define pb push_back
#define lli long long int
#define ll long long
#define mk make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define plli pair<lli,lli>
#define mii map<int,int>
#define mlli map<lli,lli>
#define test lli chu;cin>>chu;while(chu--)
#define loop(i,n) for(lli i=0;i<n;i++)
#define lop(i,n) for(lli i=1;i<=n;i++)
#define pp  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define S(z) z.size()
#define tom set<lli>
#define fill(a,b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()

#define en cout<<"\n"
#define YES cout<<"YES"
#define NO  cout<<"NO"
#define Yes cout<<"Yes"
#define No  cout<<"No"
#define er  cout<<"-1"

#define tks(s) string s; cin>>s
#define tk1(n) lli n; cin>>n
#define tk2(n,k) tk1(n);tk1(k)
#define tk3(a,b,c) tk2(a,b);tk1(c)
#define tk4(a,b,c,d) tk3(a,b,c);tk1(d)
#define tttt vector<lli>

#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

using namespace std;
const long long INF64 = 1e18;
lli pow2(lli a,lli n,lli p)
{
    if(a == 0)
    return 0;
    if(n == 0)
    return 1;
    if(n%2 == 0)
    return (pow2(((a%p)*(a%p))%p,n/2,p)%p);
    else
    return ((pow2(((a%p)*(a%p))%p,n/2,p)%p)*(a%p))%p;
}

int main()
{
pp;
tk2(n,k);
mlli mp;
lli ct=0,i,j;
pair<plli,plli> p[n];
loop(i,n)
{
	tk2(x,y);
	p[i].fi.fi = y-x;
	p[i].se.se = i;
	p[i].fi.se = x;
	p[i].se.fi = y ;
}
sort(p,p+n);
vector<lli> v;
	for(i=0;i<n;i++)
	{
		lli x = p[i].fi.se;
		lli y = p[i].se.fi;
		bool ok = false;
		for(j=x;j<=y;j++)
		{
			mp[j]++;
			if(mp[j]>k) ok =true;
		}
		if(ok)
		{
			v.pb(p[i].se.se);
			for(j=x;j<=y;j++)
			mp[j]--;
//			if(mp[j]>k) ok =true;
		}

	}
	cout<<S(v)<<"\n";
	sort(all(v));
	loop(i,S(v)) cout<<v[i]+1<<" ";

return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define ww 1
#ifndef w
#define debug(...) cerr << "\033[94m [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int long long
typedef long long ll;

struct T{
  int l,r,p;
};

int seg[300] , vis[300];
bool cmp(T a , T b){
  if(a.r != b.r) return a.r < b.r;
  return a.l > b.l;
}

signed main() {
  ios::sync_with_stdio(false);

  int n,k;
  cin >> n >> k;

  T ar[300];
  int mxl = 0;
  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    mxl = max(mxl , y);
    seg[x]++;
    seg[y+1]--;

    ar[i].l = x;
    ar[i].r = y;
    ar[i].p = i;
  }

  // for(int i=1;i<=n;i++){
  //   cout << ar[i].l <<" "<<ar[i].r << " "<<ar[i].p << endl;
  // }
  for(int i=2;i<=mxl+1;i++){
    seg[i] += seg[i-1];
  }
  vector<int>ans;

  for(int i=1;i<=mxl;i++){
    if(seg[i] <= k) continue;
   // debug("seg :" ,i, seg[i]);
    int left = i , right = -1 , taken = -1;
    for(int j=1;j<=n;j++){
       if(vis[ar[j].p]) continue;

       if(ar[j].r == right && ar[j].l < left){
         left = ar[j].l;
         right = ar[j].r;
         taken = ar[j].p;
       }
       else if(ar[j].l <= i && ar[j].r > right){
          left = ar[j].l;
          right = ar[j].r;
          taken = ar[j].p;
       }
    }
   // debug("value " , i , seg[i] , left , right , taken);
    vis[taken] = 1;
    ans.push_back(taken);
    for(int j=left;j<=right;j++) seg[j]--;

   // for(int j = 1;j<=mxl;j++) cout << seg[j] << " ";cout<<endl;
    if(seg[i]>k) i--;
  }

  cout << (int)ans.size() << '\n';
  for(auto i : ans) cout << i << " ";cout<<'\n';

}


#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define w 1
#ifndef w
#define debug(...) cerr << "\033[94m [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int long long
typedef long long ll;

struct T{
  int l,r,p;
};

int seg[300] , vis[300];
bool cmp(T a , T b){
  if(a.r != b.r) return a.r < b.r;
  return a.l > b.l;
}

signed main() {
  ios::sync_with_stdio(false);

  int n,k;
  cin >> n >> k;

  T ar[300];
  int mxl = 0;
  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    mxl = max(mxl , y);
    seg[x]++;
    seg[y+1]--;

    ar[i].l = x;
    ar[i].r = y;
    ar[i].p = i;
  }

  // for(int i=1;i<=n;i++){
  //   cout << ar[i].l <<" "<<ar[i].r << " "<<ar[i].p << endl;
  // }
  for(int i=2;i<=mxl+1;i++){
    seg[i] += seg[i-1];
  }
  vector<int>ans;

  for(int i=1;i<=mxl;i++){
    if(seg[i] <= k) continue;

    int left = 0 , right = 0 , taken = 0;
    for(int j=1;j<=n;j++){
       if(vis[ar[j].p]) continue;

       if(ar[j].l <=i && ar[j].r > right){
            left = ar[j].l;
            right = ar[j].r;
            taken = ar[j].p;
       }
    }
    vis[taken] = 1;
    ans.push_back(taken);
    for(int j=left;j<=right;j++) seg[j]--;
  }

  cout << (int)ans.size() << '\n';
  for(auto i : ans) cout << i << " ";cout<<'\n';

}


#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define w 1
#ifndef w
#define debug(...) cerr << "\033[94m [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int long long
typedef long long ll;
int seg[300];
vector<pair<int,int> >lrp;
vector<pair<int,int> >printer;
int ser(int k , int n){
  for(int i=1;i<=n;i++){
    if(seg[i]>k) return i;
  }
  return -1;
}

bool cmp(const pair<int,int>&a , const pair<int,int>&b){
    if(a.second != b.second) return a.second < b.second;
    return a.first > b.first;
}

map<int,int>mp;
map<int,map<int,int> >ind;
int vis[300];

signed main() {
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  int mxl = 0;
  for(int i=1;i<=n;i++){
    int l , r;
    cin >> l >> r;
    lrp.push_back({l,r});
    printer.push_back({l,r});
    seg[l]++;
    seg[r+1]--;
    mp[l] = max(mp[l] , r);
    ind[l][r] = i;
    mxl = max(mxl , r);
  }
  sort(lrp.begin() , lrp.end(),cmp);
  debug("lrp :" , lrp);
  for(int i=2;i<=mxl;i++){
    seg[i] += seg[i-1];
  }
  vector<int>idx;

  for(int i=lrp.size()-1;i>=0;i--){
    int x = lrp[i].first; int y = lrp[i].second;
    if(seg[y] > k){
      for(int j=x;j<=y;j++) if(seg[j]>0) seg[j]--;

      idx.push_back(ind[x][y]);
    }
  }
  sort(idx.begin() , idx.end());
  cout << (int)idx.size() << '\n';
  for(int i=0;i<idx.size();i++){
    for(int j=0;j<printer.size();j++){
       if(vis[j]) continue;
      int x = printer[j].first; int y = printer[j].second;
      if(ind[x][y] == idx[i]){
        vis[j] = 1;
        cout << j+1 << " ";
        break;
      }
    }
  }
  cout << '\n';
}


#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define w 1
#ifndef w
#define debug(...) cerr << "\033[94m [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int long long
typedef long long ll;

struct T{
  int l,r,p;
};

int seg[300];
bool cmp(T a , T b){
  if(a.r != b.r) return a.r < b.r;
  return a.l > b.l;
}

signed main() {
  ios::sync_with_stdio(false);

  int n,k;
  cin >> n >> k;

  T ar[300];
  int mxl = 0;
  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    mxl = max(mxl , y);
    seg[x]++;
    seg[y+1]--;

    ar[i].l = x;
    ar[i].r = y;
    ar[i].p = i;
  }
  sort(ar+1,ar+n+1 , cmp);
  // for(int i=1;i<=n;i++){
  //   cout << ar[i].l <<" "<<ar[i].r << " "<<ar[i].p << endl;
  // }
  for(int i=2;i<=mxl+1;i++){
    seg[i] += seg[i-1];
  }
  vector<int>ans;

  for(int i=n;i>=1;i--){
     if(seg[ar[i].r] > k){
       for(int j = ar[i].l ; j<= ar[i].r ;j++) seg[j]--;

       ans.push_back(ar[i].p);
     }
  }
  cout << ans.size() << '\n';
  for(auto i : ans) cout << i <<' ';cout<<'\n';
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;

using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n,k; cin>>n>>k;

    vector<int> temp(2);
    vector<vector<int> > seg(n,temp);

    vector<int> lin(202);

    for(int i=0; i<n; i++){
        cin>>seg[i][0]>>seg[i][1];
        lin[seg[i][0]]++; lin[seg[i][1]+1]--;
    }

    for(int i=1; i<201; i++){
        lin[i]+=lin[i-1];
    }

    //sort(seg.begin(), seg.end());

    vector<int> segk(n);
    vector<int> ans;
    while(1){
        int mxc=0,ind;
        for(int j=0; j<n; j++){
            int c=0; if(segk[j]==-1) continue;
            for(int i=1; i<201; i++){
                if(lin[i]<=k) continue;
                if(seg[j][0]<=i  && i<=seg[j][1]){
                    c++;
                }
            }
            if(mxc<c){ mxc=c; ind=j; }
        }
        if(mxc==0) break;
        for(int i=seg[ind][0]; i<=seg[ind][1]; i++) lin[i]--;
        ans.push_back(ind); segk[ind]=-1;
    }

    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<<" "; cout<<endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;

using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n,k; cin>>n>>k;

    vector<int> temp(2);
    vector<vector<int> > seg(n,temp);

    vector<int> lin(202);

    for(int i=0; i<n; i++){
        cin>>seg[i][0]>>seg[i][1];
        lin[seg[i][0]]++; lin[seg[i][1]+1]--;
    }

    for(int i=1; i<201; i++){
        lin[i]+=lin[i-1];
    }

    //sort(seg.begin(), seg.end());

    vector<int> segk(n);
    vector<int> ans;
    while(1){
        int mxc=0,ind;
        for(int j=0; j<n; j++){
            int c=0; if(segk[j]==-1) continue;
            for(int i=1; i<201; i++){
                if(lin[i]<=k) continue;
                if(seg[j][0]<=i  && i<=seg[j][1]){
                    c++;
                }
            }
            if(mxc<c){ mxc=c; ind=j; }
        }
        if(mxc==0) break;
        for(int i=seg[ind][0]; i<=seg[ind][1]; i++) lin[i]--;
        ans.push_back(ind); segk[ind]=-1;
    }

    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); i++) cout<<ans[i]+1<<" "; cout<<endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;

using namespace std;

vector<string> digits={ "1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011" };

ll modu=1e9+7;

ll t=1,n=1,k=1,ans=0;
vector<vector<ll> > arr;
vector<string> sarr;
vector<ll> ansarr;

void take_input(){
    cin>>n;
    cin>>k;

    vector<ll> temp(3);
    arr.resize(n,temp);

    for(int i=0; i<n; i++){
        cin>>arr[i][0]>>arr[i][1];
        arr[i][2]=i;
    }
}

void solve(){
    sort(arr.begin(), arr.end());
    int j=0;

    vector<ll> ox(2e5+2);
    priority_queue< pair<ll, ll> > max_heap;

    for(int i=1; i<=2e5; i++){
        //cout<<i<<"      ";
        while(!max_heap.empty()){
            if(arr[max_heap.top().second][1]<i) max_heap.pop();
            else break;
        }
        ox[i]+=ox[i-1];
        while(j<n && arr[j][0]==i){
            //cout<<j<<" ";
            max_heap.push( { arr[j][1]-arr[j][0]+1, j } );
            //cout<<" pushed in pq ";
            if(ox[i]<k){ ox[i]++; ox[arr[j][1]+1]--; }
            else{
                //cout<<" have to pop max ";
                ox[arr[max_heap.top().second][0]]++; ox[arr[max_heap.top().second][1]]--;
                //cout<<"  ox updated ";
                ansarr.push_back(arr[max_heap.top().second][2]);
                //cout<<"  ans taken ";
                max_heap.pop();
            }
            j++;
            //cout<<endl;
        }
        //cout<<endl;
    }
}

void print_output(){
    cout<<ansarr.size()<<endl;
    for(int i=0; i<ansarr.size(); i++) cout<<ansarr[i]+1<<" "; cout<<endl;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //cin>>t;

    while(t--){
        take_input();

        solve();

        print_output();

    }
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;

using namespace std;

vector<string> digits={ "1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011" };

ll modu=1e9+7;

ll t=1,n=1,k=1,ans=0;
vector<vector<ll> > arr;
vector<string> sarr;
vector<ll> ansarr;

void take_input(){
    cin>>n;
    cin>>k;

    vector<ll> temp(3);
    arr.resize(n,temp);

    for(int i=0; i<n; i++){
        cin>>arr[i][0]>>arr[i][1];
        arr[i][2]=i;
    }
}

void solve(){
    sort(arr.begin(), arr.end());
    int j=0;

    vector<ll> ox(2e5+2);
    priority_queue< vector<ll> > max_heap;

    for(int i=1; i<=2e5; i++){
        //cout<<i<<"      ";
        while(!max_heap.empty()){
            if(max_heap.top()[0]<i) max_heap.pop();
            else break;
        }
        ox[i]+=ox[i-1];
        while(j<n && arr[j][0]==i){
            //cout<<j<<" ";
            max_heap.push( { arr[j][1] , j } );
            ox[i]++; ox[arr[j][1]+1]--;

            if( k<ox[i] ){
                ox[i]--; ox[max_heap.top()[0]+1]++;   //cout<<"  ox updated ";
                ansarr.push_back(arr[max_heap.top()[1]][2]);  //cout<<"  ans taken ";
                max_heap.pop();                                   //cout<<" have to pop max ";
            }
            j++;  //cout<<endl;
        }
        //cout<<endl;
    }
}

void print_output(){
    cout<<ansarr.size()<<endl;
    for(int i=0; i<ansarr.size(); i++) cout<<ansarr[i]+1<<" "; cout<<endl;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //cin>>t;

    while(t--){
        take_input();

        solve();

        print_output();

    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    if(a.S - a.F != b.S - b.F){
        return a.S - a.F < b.S - b.F;
    }
    if(a.F != b.F){
        return a.F < b.F;
    }
    return a.S < b.S;
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    ll q[201]={0};
    f(i,0,n){
        //cout<<arr[i].F<<" "<<arr[i].S<<endl;
        bool ok = 1;
        f(j,arr[i].F,arr[i].S+1){
            if(q[j] == k){
                ok = 0;
                break;
            }
        }
        if(ok){
            f(j,arr[i].F,arr[i].S+1){
                q[j]++;
            }
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[8000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    return a.S < b.S;
}
void update(ll idx,ll l,ll r,ll x,ll y){
    if(l > y || r < x){
        return;
    }
    if(l == r){
        seg[idx].val++;
        return;
    }
    ll mid = (l+r)/2;
    update(2*idx,l,mid,x,y);
    update(2*idx + 1,mid+1,r,x,y);
    seg[idx].val = max(seg[idx*2].val,seg[2*idx+1].val);
}
ll query(ll idx,ll l,ll r,ll x,ll y){
    if(l > y || r < x){
        return 0;
    }
    if(l >= x && r <= y){
        return seg[idx].val;
    }
    ll mid = (l+r)/2;
    return max(query(2*idx,l,mid,x,y),query(2*idx+1,mid+1,r,x,y));
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    f(i,0,n){
        if(query(1,1,2e5+5,arr[i].F,arr[i].S) < k){
            update(1,1,2e5+5,arr[i].F,arr[i].S);
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[8000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    return a.S < b.S;
}
void update(ll idx,ll l,ll r,ll x,ll y){
    if(l > y || r < x){
        return;
    }
    if(l >= x && r <= y){
        seg[idx].val++;
        return;
    }
    ll mid = (l+r)/2;
    update(2*idx,l,mid,x,y);
    update(2*idx + 1,mid+1,r,x,y);
    seg[idx].val = max(seg[idx*2].val,seg[2*idx+1].val);
}
ll query(ll idx,ll l,ll r,ll x,ll y){
    if(l > y || r < x){
        return 0;
    }
    if(l >= x && r <= y){
        return seg[idx].val;
    }
    ll mid = (l+r)/2;
    return max(query(2*idx,l,mid,x,y),query(2*idx+1,mid+1,r,x,y));
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    f(i,0,n){
        if(query(1,1,2e5+5,arr[i].F,arr[i].S) < k){
            update(1,1,2e5+5,arr[i].F,arr[i].S);
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    return a.S < b.S;
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    ll q[201]={0};
    f(i,0,n){
        //cout<<arr[i].F<<" "<<arr[i].S<<endl;
        bool ok = 1;
        f(j,arr[i].F,arr[i].S+1){
            if(q[j] == k){
                ok = 0;
                break;
            }
        }
        if(ok){
            f(j,arr[i].F,arr[i].S+1){
                q[j]++;
            }
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    if(a.S - a.F != b.S - b.F){
        return a.S - a.F < b.S - b.F;
    }
    if(a.F != b.F){
        return a.F < b.F;
    }
    return a.S < b.S;
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    ll q[201]={0};
    f(i,0,n){
        cout<<arr[i].F<<" "<<arr[i].S<<endl;
        bool ok = 1;
        f(j,arr[i].F,arr[i].S+1){
            if(q[j] == k){
                ok = 0;
                break;
            }
        }
        if(ok){
            f(j,arr[i].F,arr[i].S+1){
                q[j]++;
            }
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Codeforces Round #595 (Div. 3)
bool cmp(ii a,ii b){
    if(a.S - a.F != b.S - b.F){
        return a.S - a.F < b.S - b.F;
    }
    return a.F < b.F;
}
int main(void){
    fastio;
    ll n,k;
    c(n);
    c(k);
    ll l[n],r[n];
    vii arr;
    map<ii,set<ll> >mp;
    vll ans;
    f(i,0,n){
        c(l[i]);
        c(r[i]);
        arr.pb(ii(l[i],r[i]));
        mp[arr.back()].insert(i+1);
    }
    sort(all(arr),cmp);
    ll q[201]={0};
    f(i,0,n){
        bool ok = 1;
        f(j,arr[i].F,arr[i].S+1){
            if(q[j] == k){
                ok = 0;
                break;
            }
        }
        if(ok){
            f(j,arr[i].F,arr[i].S+1){
                q[j]++;
            }
        }
        else{
            ll pos = 0;
            for(auto x:mp[arr[i]]){
                pos = x;
                mp[arr[i]].erase(x);
                break;
            }
            ans.pb(pos);
        }
    }
    sort(all(ans));
    pl(ans.size());
    for(auto x:ans){
        ps(x);
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int l[x],r[x];
    for (int i=0; i<x; i++)
        cin>>l[i]>>r[i];
    int ans=0;
    vector<int>best;
    for (int i=0; i<x; i++)
    {
        int cnt[209]= {};
        int c=0;
        vector<int>temp;
        for (int j=i; j<x; j++)
        {
            bool valid=1;
            for (int m=l[j]; m<=r[j]; m++)
            {
                cnt[m]++;

                if (cnt[m]>k)
                    valid=0;
            }
            if (!valid)
            {
                for (int m=l[j]; m<=r[j]; m++)
                    cnt[m]--;
            }
            else
            {
                temp.push_back(j+1);
                c++;
            }
        }
        if (ans<c)
        {
            ans=c;
            best=temp;
        }
    }
    cout<<x-ans<<endl;
    set<int>st;
    for (int i=1; i<=x; i++)
        st.insert(i);
    for (auto j:best)
        st.erase(j);
    for (auto j:st)
        cout<<j<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
bool visited[209];
set<pair<int,int>>st[209];
int main()
{
    FASTINOUT;
    int x,k,l,r;
    cin>>x>>k;
    for (int i=0; i<x; i++)
    {
        cin>>l>>r;
        for (int j=l; j<=r; j++)
        {
            st[j].insert({r,i});
        }
    }
    vector<int>ans;
    for (int i=1; i<=200; i++)
    {
        if (st[i].empty())
            continue;
        set<pair<int,int>>temp;
        for (auto j:st[i])
        {
            if (!visited[j.second])
                temp.insert({j.first,j.second});
        }
        st[i]=temp;
        while (st[i].size()>k)
        {
            pair<int,int>t=*st[i].rbegin();
            visited[t.second]=1;
            ans.push_back(t.second+1);
            st[i].erase(*st[i].rbegin());
        }
    }
    cout<<ans.size()<<endl;
    for (auto j:ans)
        cout<<j<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int l[x],r[x];
    for (int i=0; i<x; i++)
        cin>>l[i]>>r[i];
    int ans=0;
    vector<int>best;
    for (int i=0; i<x; i++)
    {
        int cnt[209]= {};
        int c=0;
        vector<int>temp;
        set<pair<int,int>>seg;
        for (int j=i; j<x; j++)
        {
            bool valid=1;
            vector<int>point;
            for (int m=l[j]; m<=r[j]; m++)
            {
                cnt[m]++;
                if (cnt[m]>k)
                {
                    valid=0;
                    point.push_back(m);
                }
            }
            if (!valid)
            {
                int mx_seg=0,pos=0;
                for (int m=0; m<c; m++)
                {
                    bool ok=1;
                    for (int z=0; z<point.size(); z++)
                    {
                        if (l[temp[m]]<=point[z]&&r[temp[m]]>=point[z])
                            continue;
                        else
                            ok=0;
                    }
                    if (ok)
                    {
                        if (r[temp[m]]-l[temp[m]]>mx_seg)
                        {
                            mx_seg=r[temp[m]]-l[temp[m]];
                            pos=temp[m];
                        }
                    }
                }
                for (int m=l[pos]; m<=r[pos]; m++)
                    cnt[m]--;
            }
            else
            {
                temp.push_back(j);
                c++;
            }
        }
        if (ans<c)
        {
            ans=c;
            best=temp;
        }
    }
    cout<<x-ans<<endl;
    set<int>st;
    for (int i=0; i<x; i++)
        st.insert(i);
    for (auto j:best)
        st.erase(j);
    for (auto j:st)
        cout<<j+1<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int l[x],r[x];
    for (int i=0; i<x; i++)
        cin>>l[i]>>r[i];
    int ans=0;
    vector<int>best;
    for (int i=0; i<x; i++)
    {
        int cnt[209]= {};
        vector<int>temp;
        set<pair<int,int>>seg;
        for (int j=i; j<x; j++)
        {
            bool valid=1;
            vector<int>point;
            for (int m=l[j]; m<=r[j]; m++)
            {
                cnt[m]++;
                if (cnt[m]>k)
                {
                    valid=0;
                    point.push_back(m);
                }
            }
            if (!valid)
            {
                temp.push_back(j);
                int mx_seg=0,pos=0;
                for (int m=0; m<temp.size(); m++)
                {
                    bool ok=1;
                    for (int z=0; z<point.size(); z++)
                    {
                        if (l[temp[m]]<=point[z]&&r[temp[m]]>=point[z])
                            continue;
                        else
                            ok=0;
                    }
                    if (ok)
                    {
                        if (r[temp[m]]-l[temp[m]]+1>mx_seg)
                        {
                            mx_seg=r[temp[m]]-l[temp[m]];
                            pos=temp[m];
                        }
                    }
                }
                auto it=find(temp.begin(),temp.end(),pos);
                if (it!=temp.end())
                    temp.erase(it);
                for (int m=l[pos]; m<=r[pos]; m++)
                    cnt[m]--;
            }
            else
                temp.push_back(j);

        }
        if (ans<temp.size())
        {
            ans=temp.size();
            best=temp;
        }
    }
    cout<<x-ans<<endl;
    set<int>st;
    for (int i=0; i<x; i++)
        st.insert(i);
    for (auto j:best)
        st.erase(j);
    for (auto j:st)
        cout<<j+1<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int n,k;
map<int,vector<pair<int,int>>> mp;

struct point
{
	int x;
	int y;
	int z;
	int idx;
};

point a[N];

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	rep(i,1,n)
	{
		cin >> a[i].x;
		cin >> a[i].y;
		a[i].z = a[i].y - a[i].x;
		a[i].idx=i;
		rep(j,a[i].x,a[i].y)
		{
			mp[j].pb({a[i].z,i});
		}
	}
	vi ans;
	mi mx;
	rep(i,1,200)
	{
		vector<pair<int,int>> v = mp[i];
		int x= v.size();
		for(pair<int,int> xx:v)
		{
			if(mx[xx.second]==1)
			{
				x--;
			}
		}
		if(x>k)
		{
			sort(all(v));
			reverse(all(v));
			for(pair<int,int> xx:v)
			{
				if(x==k)
				{
					break;
				}
				if(mx[xx.second]==1)
				{
					continue;
				}
				else
				{
					mx[xx.second]=1;
					ans.pb(xx.second);
					x--;
				}
			}
		}
	}
	cout << ans.size() << endl;
	for(int xx:ans)
	{
		cout << xx << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int n,k;
map<int,vector<pair<int,int>>> mp;

struct point
{
	int x;
	int y;
	int z;
	int idx;
};

point a[N];

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	rep(i,1,n)
	{
		cin >> a[i].x;
		cin >> a[i].y;
		a[i].z = a[i].y - a[i].x;
		a[i].idx=i;
		rep(j,a[i].x,a[i].y)
		{
			mp[j].pb({a[i].z,i});
		}
	}
	vi ans;
	set<int> s;
	rep(i,1,200)
	{
		vector<pair<int,int>> v = mp[i];
		int x= v.size();
		for(pair<int,int> xx:v)
		{
			if(s.find(xx.second)!=s.end())
			{
				x--;
			}
		}
		if(x>k)
		{
			sort(all(v));
			reverse(all(v));
			for(pair<int,int> xx:v)
			{
				if(x==k)
				{
					break;
				}
				if(s.find(xx.second)!=s.end())
				{
					continue;
				}
				else
				{
					s.insert(xx.second);
					x--;
				}
			}
		}
	}
	cout << s.size() << endl;
	for(int xx:s)
	{
		cout << xx << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int n,k;
map<int,vector<pair<int,int>>> mp;

struct point
{
	int x;
	int y;
	int z;
	int idx;
};

point a[N];

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	rep(i,1,n)
	{
		cin >> a[i].x;
		cin >> a[i].y;
		a[i].z = a[i].y - a[i].x;
		a[i].idx=i;
		rep(j,a[i].x,a[i].y)
		{
			mp[j].pb({a[i].y,i});
		}
	}
	vi ans;
	mi mx;
	rep(i,1,200)
	{
		vector<pair<int,int>> v = mp[i];
		int x= v.size();
		for(pair<int,int> xx:v)
		{
			if(mx[xx.second]==1)
			{
				x--;
			}
		}
		if(x>k)
		{
			sort(all(v));
			reverse(all(v));
			for(pair<int,int> xx:v)
			{
				if(x==k)
				{
					break;
				}
				if(mx[xx.second]==1)
				{
					continue;
				}
				else
				{
					mx[xx.second]=1;
					ans.pb(xx.second);
					x--;
				}
			}
		}
	}
	cout << ans.size() << endl;
	for(int xx:ans)
	{
		cout << xx << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int n,k;
map<int,vector<pair<int,int>>> mp;

struct point
{
	int x;
	int y;
	int z;
	int idx;
};

point a[N];

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	rep(i,1,n)
	{
		cin >> a[i].x;
		cin >> a[i].y;
		a[i].z = a[i].y - a[i].x;
		a[i].idx=i;
		rep(j,a[i].x,a[i].y)
		{
			mp[j].pb({a[i].y,i});
		}
	}
	vi ans;
	set<int> s;
	rep(i,1,200)
	{
		vector<pair<int,int>> v = mp[i];
		int x= v.size();
		for(pair<int,int> xx:v)
		{
			if(s.find(xx.second)!=s.end())
			{
				x--;
			}
		}
		if(x>k)
		{
			sort(all(v));
			reverse(all(v));
			for(pair<int,int> xx:v)
			{
				if(x==k)
				{
					break;
				}
				if(s.find(xx.second)!=s.end())
				{
					continue;
				}
				else
				{
					s.insert(xx.second);
					x--;
				}
			}
		}
	}
	cout << s.size() << endl;
	for(int xx:s)
	{
		cout << xx << " ";
	}
}


#include<bits/stdc++.h>
#include<list>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define MAX 1e18
#define N 200005
#define trace1(x)                cout << #x << ": " << x << "\n";
#define trace2(x, y)             cout << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z<<"\n" ;
#define trace4(a, b, c, d)       cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d<<"\n" ;
ll mod1 = 998244353;
ll mod= 1e9 + 7;
//ll p = 100;
bool comp(pair<int,int> a,pair<int,int> b)
{
    return a.ss<b.ss;
}

void solve()
{
  ll n,k;
  cin>>n>>k;
  int a[201][201];
  int c[201];
  for(int i = 0;i<=200;++i)
  for(int j = 0;j<=200;++j)
  a[i][j] = 0;
  for(int i =0;i<=200;++i)
  c[i] = 0;
  for(int i = 1;i<=n;++i)
  {
    ll l,r;
    cin>>l>>r;
    for(int j =l;j<=r;++j)
    {a[j][i] = 1; c[j]++;}
  }
  int count =0 ;vector<int> ans;
  while(1)
  {
  vector<int> b[201];
  int f = 0;
  for(int i = 1;i<=200;++i)
  {
    if(c[i]>k)
    {
	  f = 1;
      for(int j = 1;j<=200;++j)
      {
        if(a[i][j])
        b[j].push_back(i);
      }
    }
  }

  if( f ==0) break;

  int maxi = 0 ; int r;

  for(int i = 1;i<=200;++i)
  {
    int s = b[i].size(); int x = i;

    if(maxi<s)
    {
      maxi = s;
      r = x;
    }
  }

  ++count;ans.pb(r);
  for(int i = 0;i<maxi;++i)

    a[b[r][i]][r] = 0,c[b[r][i]]--;

  }

  cout<<count<<"\n";
  sort(ans.begin(),ans.end());
  for(int i =0;i<count;++i)
  cout<<ans[i]<<" ";
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll t=1;
    //cin>>t;

    while(t--)
    {
      solve();
      cout<<"\n";
    }
    return 0;

}


#include<bits/stdc++.h>
#include<list>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define MAX 1e18
#define N 200005
#define trace1(x)                cout << #x << ": " << x << "\n";
#define trace2(x, y)             cout << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z<<"\n" ;
#define trace4(a, b, c, d)       cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d<<"\n" ;
ll mod1 = 998244353;
ll mod= 1e9 + 7;
//ll p = 100;
bool comp(pair<int,int> a,pair<int,int> b)
{
    return a.ss<b.ss;
}

void solve()
{
  ll n,k;
  cin>>n>>k;
  int a[201][201];
  int c[201];
  for(int i = 0;i<=200;++i)
  for(int j = 0;j<=200;++j)
  a[i][j] = 0;
  for(int i =0;i<=200;++i)
  c[i] = 0;
  for(int i = 1;i<=n;++i)
  {
    ll l,r;
    cin>>l>>r;
    for(int j =l;j<=r;++j)
    {a[j][i] = 1; c[j]++;}
  }
  int count =0 ;vector<int> ans;
  while(1)
  {
  vector<int> b[201];
  int f = 0;
  for(int i = 1;i<=200;++i)
  {
    if(c[i]>k)
    {
	  f = 1;
      for(int j = 1;j<=200;++j)
      {
        if(a[i][j])
        b[j].push_back(i);
      }
    }
  }

  if( f ==0) break;

  int maxi = 0 ; int r;

  for(int i = 1;i<=200;++i)
  {
    int s = b[i].size(); int x = i;

    if(maxi<=s)
    {
      maxi = s;
      r = x;
    }
  }

  ++count;ans.pb(r);
  for(int i = 0;i<maxi;++i)

    a[b[r][i]][r] = 0,c[b[r][i]]--;

  }

  cout<<count<<"\n";
  sort(ans.begin(),ans.end());
  for(int i =0;i<count;++i)
  cout<<ans[i]<<" ";
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll t=1;
    //cin>>t;

    while(t--)
    {
      solve();
      cout<<"\n";
    }
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ld long double
#define ff first
#define ss second
#define pi pair<int,int>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define forall(i,n) for(int i=0;i<n;i++)
ll mod = 998244353;
ll mod1 = 1e9 + 7;
const int N= 300;
int n,k;;
set<pi> add[N],rem[N],curr;

int main(){
 /*   cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
*/	cin>>n>>k;
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		add[l].insert(mp(r,i+1));
		rem[r+1].insert(mp(r,i+1));
	}
	set<pi>::iterator it;
	vector<int> ans;

	for(int i=0;i<N;i++){
		for(it=add[i].begin();it!=add[i].end();it++)
		curr.insert((*it));
		for(it=rem[i].begin();it!=rem[i].end();it++)
		if(curr.find(*it)!=curr.end())
		curr.erase(*it);

	//cout<<curr.size()<<" ";
		while(curr.size()>k){
			it=--curr.end();
			ans.pb((*it).ss);
			curr.erase(it);
		}
	}
	sort(ans.begin(),ans.end());

	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
#include<list>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define MAX 1e18
#define N 200005
#define trace1(x)                cout << #x << ": " << x << "\n";
#define trace2(x, y)             cout << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z<<"\n" ;
#define trace4(a, b, c, d)       cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d<<"\n" ;
ll mod1 = 998244353;
ll mod= 1e9 + 7;
//ll p = 100;
bool comp(pair<int,int> a,pair<int,int> b)
{
    return a.ss<b.ss;
}

void solve()
{
  ll n,k;
  cin>>n>>k;
  int a[201][201];
  int c[201];
  for(int i = 0;i<=200;++i)
  for(int j = 0;j<=200;++j)
  a[i][j] = 0;
  for(int i =0;i<=200;++i)
  c[i] = 0;
  for(int i = 1;i<=n;++i)
  {
    ll l,r;
    cin>>l>>r;
    for(int j =l;j<=r;++j)
    {a[j][i] = 1; c[j]++;}
  }
  int count =0 ;vector<int> ans;
  while(1)
  {
  vector<int> b[201];
  int f = 0;
  for(int i = 1;i<=200;++i)
  {
    if(c[i]>k)
    {
	  f = 1;
      for(int j = 1;j<=200;++j)
      {
        if(a[i][j])
        b[j].push_back(i);
      }
    }
  }

  if( f ==0) break;

  int maxi = 0 ; int r;

  for(int i = 1;i<=200;++i){
    int s = b[i].size(); int x = i;

    if(maxi<s)
    {
      maxi = s;
      r = x;
    }else if(maxi==s){
    	if(r>x)
    	r=x;
	}
  }

  ++count;ans.pb(r);
  for(int i = 0;i<maxi;++i)

    a[b[r][i]][r] = 0,c[b[r][i]]--;

  }

  cout<<count<<"\n";
  sort(ans.begin(),ans.end());
  for(int i =0;i<count;++i)
  cout<<ans[i]<<" ";
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll t=1;
    //cin>>t;

    while(t--)
    {
      solve();
      cout<<"\n";
    }
    return 0;

}


#include<bits/stdc++.h>
#include<list>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define MAX 1e18
#define N 200005
#define trace1(x)                cout << #x << ": " << x << "\n";
#define trace2(x, y)             cout << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z<<"\n" ;
#define trace4(a, b, c, d)       cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d<<"\n" ;
ll mod1 = 998244353;
ll mod= 1e9 + 7;
//ll p = 100;
bool comp(pair<int,int> a,pair<int,int> b)
{
    return a.ss<b.ss;
}

void solve()
{
  ll n,k;
  cin>>n>>k;
  int a[201][201];
  int c[201];
  for(int i = 0;i<=200;++i)
  for(int j = 0;j<=200;++j)
  a[i][j] = 0;
  for(int i =0;i<=200;++i)
  c[i] = 0;
  for(int i = 1;i<=n;++i)
  {
    ll l,r;
    cin>>l>>r;
    for(int j =l;j<=r;++j)
    {a[j][i] = 1; c[j]++;}
  }
  int count =0 ;vector<int> ans;
  while(1)
  {
  vector<int> b[201];
  int f = 0;
  for(int i = 1;i<=200;++i)
  {
    if(c[i]>k)
    {
	  f = 1;
      for(int j = 1;j<=200;++j)
      {
        if(a[i][j])
        b[j].push_back(i);
      }
    }
  }

  if( f ==0) break;

  int maxi = 0 ; int r;

  for(int i = 1;i<=200;++i){
    int s = b[i].size(); int x = i;

    if(maxi<s)
    {
      maxi = s;
      r = x;
    }else if(maxi==s){
    	if(r<x)
    	r=x;
	}
  }

  ++count;ans.pb(r);
  for(int i = 0;i<maxi;++i)

    a[b[r][i]][r] = 0,c[b[r][i]]--;

  }

  cout<<count<<"\n";
  sort(ans.begin(),ans.end());
  for(int i =0;i<count;++i)
  cout<<ans[i]<<" ";
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll t=1;
    //cin>>t;

    while(t--)
    {
      solve();
      cout<<"\n";
    }
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ld long double
#define ff first
#define ss second
#define pi pair<int,int>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define forall(i,n) for(int i=0;i<n;i++)
ll mod = 998244353;
ll mod1 = 1e9 + 7;
const int N= 200;
int n,k;;
set<pi> add[N],rem[N],curr;

int main(){
 /*   cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
*/	cin>>n>>k;
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		add[l].insert(mp(r,i+1));
		rem[r+1].insert(mp(r,i+1));
	}
	set<pi>::iterator it;
	vector<int> ans;

	for(int i=0;i<N;i++){
		for(it=add[i].begin();it!=add[i].end();it++)
		curr.insert((*it));
		for(it=rem[i].begin();it!=rem[i].end();it++)
		if(curr.find(*it)!=curr.end())
		curr.erase(*it);

	//cout<<curr.size()<<" ";
		while(curr.size()>k){
			it=--curr.end();
			ans.pb((*it).ss);
			curr.erase(it);
		}
	}
	sort(ans.begin(),ans.end());

	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=m;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=m;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) >= k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	if(tp == 0) return 0;
	sort(ans+1,ans+tp+1);
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=m;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=m;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) > k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	if(tp == 0) return 0;
	sort(ans+1,ans+tp+1);
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=200;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=200;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) > k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	if(tp == 0) return 0;
	sort(ans+1,ans+tp+1);
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=m;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=m;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) > k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	if(tp == 0) return 0;
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=m;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=m;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) > k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 200005;

int n,m,k,x[N],y[N],tmp,diff[N];
int tp, ans[N];
struct dt{int l,r,id;};
priority_queue<dt> q;
queue<dt> r[N]; // r[i]: the end points of segment begins at i
bool operator <(dt a, dt b){
	return a.r < b.r;
}

void update(int x, int v){
	for(int i=x;i<=m;i+=i&(-i))
		diff[i] += v;
}

int query(int x){
	int ans = 0;
	for(int i=x;i>=1;i-=i&(-i))
		ans += diff[i];
	return ans;
}

int main(){
	scanf("%d%d",&n,&k);
	tmp = 0x7fffffff;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		tmp = min(tmp, x[i]);
	}
	for(int i=1;i<=n;++i){
		x[i] = x[i] - tmp + 1;
		y[i] = y[i] - tmp + 1;

		//cout<<x[i]<<" "<<y[i]<<" "<<i<<endl;

		m = max(m, y[i]);

		r[x[i]].push((dt){x[i],y[i],i});
		// ++ diff[x[i]]; -- diff[y[i]+1];
		update(x[i], 1);
		update(y[i]+1, -1);
	}
	//cout<<endl;

	for(int i=1;i<=m+1;++i){
		while(!r[i].empty()){
			q.push(r[i].front()); r[i].pop();
		}
		//if(i==2) cout<<query(2)<<endl;
		while(query(i) > k){
			//puts("fuck");
			//cout<<"ha:"<<i<<" "<<query(i)<<endl;

			dt u = q.top(); q.pop();

			ans[++tp] = u.id;

			//-- diff[u.l]; ++ diff[u.r+1];
			update(u.l, -1);
			update(u.r + 1, 1);

			//cout<<u.id<<" "<<query(1)<<" "<<query(2)<<endl;
		}
	}
	printf("%d\n",tp);
	if(tp == 0) return 0;
	sort(ans+1,ans+tp+1);
	for(int i=1;i<tp;++i)
		printf("%d ", ans[i]);
	printf("%d\n",ans[tp]);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  while(cin >> n >> k) {
    vector<int> l(n), r(n), X(205, 0);
    for(int i = 0; i < n; ++i) {
      cin >> l[i] >> r[i];
      for(int j = l[i]; j <= r[i]; ++j) {
        X[j]++;
      }
    }
    vector<int> ans;
    while(1) {
      int mx = 0, L, R, pos;
      for(int i = 0; i < n; ++i) {
        int c = 0;
        for(int j = l[i]; j <= r[i]; ++j) {
          if(X[j] > k) {
            ++c;
          }
        }
        if(c > mx) {
          mx = c;
          L = l[i];
          R = r[i];
          pos = i + 1;
        }
      }
      if(mx == 0) {
        break;
      } else {
        ans.push_back(pos);
        for(int i = L; i <= R; ++i) {
          X[i]--;
        }
        l[pos - 1] = 0;
        r[pos - 1] = -1;
      }
    }
    cout << ans.size() << '\n';
    for(int i : ans) {
      cout << i << ' ';
    }
    cout << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, n;
  while(cin >> n >> k) {
    vector<tuple<int, int, int, bool, int> > val(n);
    vector<int> c(205, 0);
    for(int i = 0; i < n; ++i) {
      int l, r;
      cin >> l >> r;
      val[i] = { l - r + 1, l, r, 0 , i + 1 };
      for(int j = l; j <= r; ++j) {
        c[j]++;
      }
    }
    sort(val.begin(), val.end());
    for(int i = 200; i >= 0; --i) {
      if(c[i] > k) {
        int m = c[i] - k;
        for(int j = 0; j < m; ++j) {
          for(auto l = val.begin(); l != val.end(); ++l) {
            int S, L, R, pos;
            bool f;
            tie(S, L, R, f, pos) = *l;
            if(!f && i >= L && i <= R) {
              f = 1;
              for(int x = L; x <= R; ++x) {
                c[x]--;
              }
              *l = { S, L, R, f, pos };
              break;
            }
          }
        }
      }
    }
    vector<int> ans;
    for(auto i = val.begin(); i != val.end(); ++i) {
      int S, L, R, pos;
      bool f;
      tie(S, L, R, f, pos) = *i;
      if(f) {
        ans.push_back(pos);
      }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << '\n';
    for(int i : ans) {
      cout << i << ' ';
    }
    cout << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  while(cin >> n >> k) {
    vector<int> L(n), R(n), X(205, 0);
    for(int i = 0; i < n; ++i) {
      cin >> L[i] >> R[i];
      for(int j = L[i]; j <= R[i]; ++j) {
        X[j]++;
      }
    }
    vector<tuple<int, int, int, int> > val(n);
    for(int i = 0; i < n; ++i) {
      int c = 0;
      for(int j = L[i]; j <= R[i]; ++j) {
        if(X[j] > k) {
          ++c;
        }
      }
      val[i] = { c, L[i], R[i], i + 1 };
    }
    vector<int> ans;
    while(1) {
      bool f = 0;
      for(int i = 1; i <= 200; ++i) {
        if(X[i] > k) {
          f = 1;
          break;
        }
      }
      if(f) {
        sort(val.rbegin(), val.rend());
        int c, l, r, pos;
        tie(c, l, r, pos) = *val.begin();
        for(int i = l; i <= r; ++i) {
          --X[i];
        }
        ans.push_back(pos);
        c = l = r = -1;
        *val.begin() = { c, l, r, pos };
        for(auto i = val.begin(); i != val.end(); ++i) {
          int c, l, r, pos;
          tie(c, l, r, pos) = *i;
          int cnt = 0;
          for(int j = l; j <= r; ++j) {
            if(X[j] > k) {
              ++cnt;
            }
          }
          *i = { cnt, l, r, pos };
        }
      } else {
        break;
      }
    }
    cout << ans.size() << '\n';
    for(int i : ans) cout << i << ' ';
    cout << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  while(cin >> n >> k) {
    vector<int> l(n), r(n), X(205, 0);
    for(int i = 0; i < n; ++i) {
      cin >> l[i] >> r[i];
      for(int j = l[i]; j <= r[i]; ++j) {
        X[j]++;
      }
    }
    vector<int> ans;
    vector<bool> f(n, 0);
    for(int i = 1; i <= 200; ++i) {
      while(X[i] > k) {
        int pos = -1, mx = -1;
        for(int j = 0; j < n; ++j) {
          if(!f[j]) {
            if(l[j] <= i) {
              if(r[j] > mx) {
                mx = r[j];
                pos = j;
              }
            }
          }
        }
        ans.push_back(pos + 1);
        f[pos] = 1;
        for(int j = l[pos]; j <= r[pos]; ++j) {
          --X[j];
        }
      }
    }
    cout << ans.size() << '\n';
    for(int i : ans) {
      cout << i << ' ';
    }
    cout << '\n';
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    int num;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend operator<(seg a,seg b)
    {
        if(a.num==b.num)
            return a.r-a.l>b.r-b.l;
        return a.num>b.num;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0;i<=mx;++i)
        cf[i]+=cf[i-1];
    while(true)
    {
        bool flag=false;
        for(int i=0;i<n;++i)
        {
            int cnt=0;
            for(int j=arr[i].l;j<=arr[i].r;++j)
            {
                if(cf[j]>k)
                {
                    flag=true;
                    cnt++;
                }
            }
            arr[i].num=cnt;
        }
        if(!flag)
            break;
        sort(arr+now,arr+n);
        ans.push_back(arr[now].index);
        for(int j=arr[now].l;j<=arr[now].r;++j)
        {
            cf[j]--;
        }
        now++;
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();++i)
        printf("%d ",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    int num;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend operator<(seg a,seg b)
    {
        if(a.num==b.num)
            return a.r-a.l>b.r-b.l;
        return a.num>b.num;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0; i<=mx; ++i)
        cf[i]+=cf[i-1];
    for(int i=mn;i<=mx;++i)
        printf("%d ",cf[i]);
    puts("");
    while(true)
    {
        for(int i=now; i<n; ++i)
        {
            int cnt=0;
            for(int j=arr[i].l; j<=arr[i].r; ++j)
            {
                if(cf[j]>k)
                {
                    cnt++;
                }
            }
            arr[i].num=cnt;
        }
        bool flag=false;
        for(int i=mn;i<=mx;++i)
            if(cf[i]>k)
                flag=true;
        if(!flag)
            break;
        sort(arr+now,arr+n);
        ans.push_back(arr[now].index);
        for(int j=arr[now].l; j<=arr[now].r; ++j)
        {
            cf[j]--;
        }
        now++;
    }
    printf("%d\n",ans.size());
    for(int i=0; i<ans.size(); ++i)
        printf("%d ",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    int num;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend operator<(seg a,seg b)
    {
        if(a.num==b.num)
            return a.r-a.l>b.r-b.l;
        return a.num>b.num;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0; i<=mx; ++i)
        cf[i]+=cf[i-1];
//    for(int i=mn;i<=mx;++i)
//        printf("%d ",cf[i]);
//    puts("");
    while(true)
    {
        for(int i=now; i<n; ++i)
        {
            int cnt=0;
            for(int j=arr[i].l; j<=arr[i].r; ++j)
            {
                if(cf[j]>k)
                {
                    cnt++;
                }
            }
            arr[i].num=cnt;
        }
        bool flag=false;
        for(int i=mn;i<=mx;++i)
            if(cf[i]>k)
                flag=true;
        if(!flag)
            break;
        sort(arr+now,arr+n);
        ans.push_back(arr[now].index);
        for(int j=arr[now].l; j<=arr[now].r; ++j)
        {
            cf[j]--;
        }
        now++;
    }
    printf("%d\n",ans.size());
    for(int i=0; i<ans.size(); ++i)
        printf("%d ",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
#define Mod(a,b) a<b?a:a%b+b //重定义取模,按照欧拉定理的条件
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend bool operator < (seg a,seg b)
    {
        return a.r>b.r;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0; i<=mx; ++i)
        cf[i]+=cf[i-1];
    sort(arr,arr+n);
    for(int i=mn;i<=mx;++i)
    {
        if(cf[i]>k)
        {
            for(int j=0;j<n&&cf[i]>k;++j)
            {
                if(hasdel[j]) continue;
                if(i>=arr[j].l&&i<=arr[j].r)
                {
                    hasdel[j]=true;
                    ans.push_back(arr[j].index);
                    for(int p=arr[j].l;p<=arr[j].r;++p)
                    {
                        cf[p]--;
                    }
                }
            }
        }
    }
    printf("%d\n",ans.size());
    for(int elem:ans)
        printf("%d ",elem);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    int num;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend operator<(seg a,seg b)
    {
        return a.num>b.num;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0;i<=mx;++i)
        cf[i]+=cf[i-1];
//    for(int i=mn;i<=mx;++i)
//        printf("%d ",cf[i]);
//    printf("\n");
    while(true)
    {
        bool flag=false;
        for(int i=0;i<n;++i)
        {
            int cnt=0;
            for(int j=arr[i].l;j<=arr[i].r;++j)
            {
                if(cf[j]>k)
                {
                    flag=true;
                    cnt++;
                }
            }
            arr[i].num=cnt;
        }
        if(!flag)
            break;
        sort(arr+now,arr+n);
        ans.push_back(arr[now].index);
        for(int j=arr[now].l;j<=arr[now].r;++j)
        {
            cf[j]--;
        }
        now++;
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();++i)
        printf("%d ",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=3e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-6;
std::mt19937 rnd(time(0));
ll qpw(ll a,ll b)
{
    ll ans=1;    //b>=0
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return qpw(a,MOD-2);
}
struct CombMath
{
    int C[1005][1005];
    void init(int n)
    {
        for(int i=1; i<=n; ++i)
            C[i][0]=1;
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
    }
};

struct seg
{
    int l,r;
    int index;
    int num;
    seg(int _l=0,int _r=0):l(_l),r(_r) { }
    friend operator<(seg a,seg b)
    {
        if(a.num==b.num)
            return a.r-a.l>b.r-b.l;
        return a.num>b.num;
    }
};
seg arr[MAXN];
int cf[MAXN];
bool hasdel[MAXN];
vector<int>ans;
signed main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    int mx=-1;
    int mn=INF;
    for(int i=0; i<n; ++i)
    {
        scanf("%d%d",&arr[i].l,&arr[i].r);
        arr[i].index=i+1;
        cf[arr[i].l]++;
        cf[arr[i].r+1]--;
        mx=max(mx,arr[i].r);
        mn=min(mn,arr[i].l);
    }
    int now=0;
    for(int i=0;i<=mx;++i)
        cf[i]+=cf[i-1];
    while(true)
    {
        bool flag=false;
        for(int i=now;i<n;++i)
        {
            int cnt=0;
            for(int j=arr[i].l;j<=arr[i].r;++j)
            {
                if(cf[j]>k)
                {
                    flag=true;
                    cnt++;
                }
            }
            arr[i].num=cnt;
        }
        if(!flag)
            break;
        sort(arr+now,arr+n);
        ans.push_back(arr[now].index);
        for(int j=arr[now].l;j<=arr[now].r;++j)
        {
            cf[j]--;
        }
        now++;
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();++i)
        printf("%d ",ans[i]);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
#ifdef MYLOCAL
	ifstream in("in.txt");
	cin.rdbuf(in.rdbuf());
#endif

	int n, k;
	cin >> n >>  k;

	map<int, pair<int, int>> otr;
	map<int, set<int>> s;

	for (int i = 0; i < n; ++i)
	{
		int l, r;
		cin >> l >> r;

		otr[i] = { l, r };
		s[l].insert(i);
		s[r].insert(i);
	}

	for (auto x : otr)
	{
		auto itb = s.find(x.second.first);
		auto ite = s.find(x.second.first);

		while (itb != ite)
		{
			s[itb->first].insert(x.first);
			itb++;
		}
	}

	{
		bool stillbad = false;
		for (auto x : s)
		{
			if (x.second.size() > k)
			{
				stillbad = true;
				break;
			}
		}
		if (!stillbad)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	vector<int> toremove;

	map<int, int> otr2;

	for (auto& x : s)
	{
		for (auto id : x.second)
			otr2[id]++;
	}

	vector<pair<int, int>> inv;
	for (auto& x : otr2)
		inv.push_back({ x.second, x.first });
	sort(inv.begin(), inv.end());

	auto it = inv.rbegin();

	while (true)
	{
		auto id = (it++)->second;
		toremove.emplace_back(id);

		bool stillbad = false;
		for (auto &x : s)
		{
			x.second.erase(id);
			if (x.second.size() > k)
				stillbad = true;
		}

		if (!stillbad)
			break;
	}

	cout << toremove.size() << endl;
	for (auto x : toremove)
		cout << x + 1 << " ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
#ifdef MYLOCAL
	ifstream in("in.txt");
	cin.rdbuf(in.rdbuf());
#endif

	int n, k;
	cin >> n >>  k;

	map<int, pair<int, int>> otr;
	map<int, set<int>> s;

	for (int i = 0; i < n; ++i)
	{
		int l, r;
		cin >> l >> r;

		otr[i] = { l, r };
		s[l].insert(i);
		s[r].insert(i);
	}

	for (auto x : otr)
	{
		auto itb = s.find(x.second.first);
		auto ite = s.find(x.second.second);

		while (itb != ite)
		{
			s[itb->first].insert(x.first);
			itb++;
		}
	}

	{
		bool stillbad = false;
		for (auto x : s)
		{
			if (x.second.size() > k)
			{
				stillbad = true;
				break;
			}
		}
		if (!stillbad)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	vector<int> toremove;

	map<int, int> otr2;

	for (auto& x : s)
	{
		for (auto id : x.second)
			otr2[id]++;
	}

	vector<pair<int, int>> inv;
	for (auto& x : otr2)
		inv.push_back({ x.second, x.first });
	sort(inv.begin(), inv.end());

	auto it = inv.rbegin();

	while (true)
	{
		auto id = (it++)->second;
		toremove.emplace_back(id);

		bool stillbad = false;
		for (auto &x : s)
		{
			x.second.erase(id);
			if (x.second.size() > k)
				stillbad = true;
		}

		if (!stillbad)
			break;
	}

	cout << toremove.size() << endl;
	for (auto x : toremove)
		cout << x + 1 << " ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
#ifdef MYLOCAL
	ifstream in("in.txt");
	cin.rdbuf(in.rdbuf());
#endif

	int n, k;
	cin >> n >>  k;

	map<int, pair<int, int>> otr;
	map<int, set<int>> s;

	for (int i = 0; i < n; ++i)
	{
		int l, r;
		cin >> l >> r;

		otr[i] = { l, r };
		s[l].insert(i);
		s[r].insert(i);
	}

	for (auto x : otr)
	{
		auto itb = s.find(x.second.first);
		auto ite = s.find(x.second.second);

		while (itb != ite)
		{
			s[itb->first].insert(x.first);
			itb++;
		}
	}

	{
		bool stillbad = false;
		for (auto x : s)
		{
			if (x.second.size() > k)
			{
				stillbad = true;
				break;
			}
		}
		if (!stillbad)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	vector<int> toremove;

	while (true)
	{
		map<int, int> otr2;

		for (auto& x : s)
		{
			if (x.second.size() <= k)
				continue;

			for (auto id : x.second)
				otr2[id]++;
		}

		vector<pair<int, int>> inv;
		for (auto& x : otr2)
			inv.push_back({ x.second, x.first });
		sort(inv.begin(), inv.end());

		auto id = inv.rbegin()->second;

		toremove.emplace_back(id);

		bool stillbad = false;
		for (auto &x : s)
		{
			x.second.erase(id);
			if (x.second.size() > k)
				stillbad = true;
		}

		if (!stillbad)
			break;
	}

	cout << toremove.size() << endl;
	for (auto x : toremove)
		cout << x + 1 << " ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
#ifdef MYLOCAL
	ifstream in("in.txt");
	cin.rdbuf(in.rdbuf());
#endif

	int n, k;
	cin >> n >>  k;

	map<int, pair<int, int>> otr;
//	map<int, set<int>> s;
	set<int> pts;

	map<int, set<pair<int, int>>> add;
	map<int, set<pair<int, int>>> rem;

	for (int i = 0; i < n; ++i)
	{
		int l, r;
		cin >> l >> r;

		otr[i] = { l, r };
// 		s[l].insert(i);
// 		s[r].insert(i);

	}

	for (auto& o : otr)
	{
		auto p = make_pair(o.second.second, o.first);

		pts.insert(o.second.first);
		pts.insert(o.second.second + 1);

		add[o.second.first].insert(p);
		rem[o.second.second + 1].insert(p);
	}

	vector<int> res;

	set<pair<int, int>> s;
	for (auto p : pts)
	{
		for (auto& a : add[p])
			s.insert(a);

		for (auto& a : rem[p])
			s.erase(a);

		while (s.size() > k)
		{
			auto last = *s.rbegin();
			res.push_back(last.second);
			s.erase(prev(s.end()));
		}
	}

	cout << res.size() << endl;
	for (auto r : res)
	{
		cout << r + 1 << " ";
	}

	cout << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,a,b) for (int i=(a); i<(b);i++)
#define frr(i,a,b) for(int i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define ln(a) a.length()
#define sz(a) a.size()
int M=-100000;

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

int n,k;
cin>>n>>k;

pair<int,int> a[n];pair<int,int> b[n];
fr(i,0,n)b[i]={0,i};
map<int,vi> m;
fr(i,0,n)
{
  cin>>a[i].first>>a[i].second;
  fr(j,a[i].first,a[i].second+1)
  m[j].pb(i);
}
int tot=0;
fr(i,1,201)
{
  if(m.count(i) && m[i].size()>k)
  {
    tot+=sz(m[i])-k;
    fr(j,0,sz(m[i]))
    b[m[i][j]].first++;

  }
}
set<int> s;
vi v;

fr(i,0,201)
{
  if(m.count(i) && m[i].size()>k)
  {  int num=sz(m[i])-k;
      deque<pair<int,int> > c;
       fr(j,0,sz(m[i]))
       {
            c.pb(b[m[i][j]]);
       }
       srt(c);rev(c);
    while(num--)
    {
      if(!s.count(c[0].second))
      {v.pb(c[0].second);s.insert(c[0].second);}
       c.ppf;
    }

  }

}
cout<<sz(v)<<endl;
for(auto x:v)cout<<x+1<<" ";

}