#include <bits/stdc++.h>
using namespace std;
struct TData {
  int l, r, id;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<TData> seg;
  for (int i = 1; i <= m; ++i) {
    int r, c;
    cin >> r >> c;
    seg.push_back({n - r + 1, c, i});
  }
  sort(seg.begin(), seg.end(),
       [](const TData &x, const TData &y) { return x.l < y.l; });
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      heap;
  int l = 0;
  vector<int> res;
  for (int pos = 1; pos <= n; ++pos) {
    while (l < seg.size() && seg[l].l <= pos) {
      heap.push({seg[l].r, seg[l].id});
      ++l;
    }
    while (heap.size() && heap.top().first < pos) heap.pop();
    if (heap.size()) {
      res.push_back(heap.top().second);
      heap.pop();
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << '\n';
  for (int x : res) cout << x << ' ';
}
