#include <bits/stdc++.h>
using namespace std;
long n, m;
pair<pair<long, long>, long> p[100100];
vector<long> v;
priority_queue<pair<long, long> > q;
void read(void) {
  cin >> n >> m;
  for (long i = 1, a, b; i <= m; ++i) {
    cin >> a >> b;
    p[i - 1] = make_pair(make_pair(n + 1 - b, a), i);
  }
  sort(p, p + m);
}
void greed(void) {
  for (long i = 1, j = 0; i <= n; ++i) {
    for (; j < m && p[j].first.first <= i; ++j)
      q.push(make_pair(-p[j].first.second, p[j].second));
    while (!q.empty() && -q.top().first < i) q.pop();
    if (!q.empty()) {
      v.push_back(q.top().second);
      q.pop();
    }
  }
}
int main() {
  read();
  greed();
  cout << v.size() << "\n";
  for (long i = 0; i < v.size(); ++i) cout << v[i] << " ";
  return 0;
}
