#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<pair<int, int>, int> > a;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a.push_back(make_pair(make_pair(n - x, y - 1), i));
  }
  sort(a.begin(), a.end());
  priority_queue<pair<int, int> > q;
  vector<int> ans;
  int j = 0;
  for (int i = (0); i < (n); i++) {
    while (j < m && a[j].first.first <= i) {
      q.push(make_pair(-a[j].first.second, a[j].second));
      j++;
    }
    while (!q.empty()) {
      pair<int, int> c = q.top();
      q.pop();
      if (-c.first >= i) {
        ans.push_back(c.second);
        break;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto c : ans) printf("%d ", c + 1);
  return 0;
}
