#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, idx;
  bool operator>(const node &a) const { return r > a.r; }
} e[100005];
bool cmp(node a, node b) { return a.l < b.l; }
priority_queue<node, vector<node>, greater<node> > sp;
vector<int> ans;
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    e[i].idx = i;
    e[i].l = n - x + 1;
    e[i].r = y;
  }
  sort(e + 1, e + 1 + m, cmp);
  int now = 1;
  for (int i = 1; i <= n; i++) {
    while (now <= m && e[now].l == i) {
      sp.push(e[now]);
      now++;
    }
    while (!sp.empty() && sp.top().r < i) sp.pop();
    if (sp.empty()) continue;
    node f = sp.top();
    sp.pop();
    ans.push_back(f.idx);
  }
  reverse(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
  return 0;
}
