#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > P[100000];
set<int> Q;
vector<int> R;
int main(void) {
  int i, n, m;
  cin >> n >> m;
  for (i = 1; i <= n; i++) Q.insert(i);
  for (i = 0; i < m; i++) {
    cin >> P[i].first >> P[i].second.first;
    P[i].second.first = n + 1 - P[i].second.first;
    P[i].second.second = i + 1;
  }
  sort(P, P + m);
  for (i = 0; i < m; i++) {
    set<int>::iterator t = Q.upper_bound(P[i].second.first - 1);
    if (t != Q.end() && *t <= P[i].first) {
      R.push_back(P[i].second.second);
      Q.erase(t);
    }
  }
  cout << R.size() << endl;
  for (int i = 0; i < R.size(); i++) cout << R[i] << " ";
  return 0;
}
