#include <bits/stdc++.h>
using namespace std;
const int maxn = 100111;
struct zz {
  int l, r;
  int id;
  bool operator<(const zz& cmp) const { return l < cmp.l; }
} zx;
struct z2 {
  int l;
  int r;
  int id;
  bool operator<(const z2& cmp) const { return r > cmp.r; }
} t2;
vector<zz> v;
priority_queue<z2> q;
int a[maxn];
int n, m;
int x, y, temp, num, now, sum;
int main() {
  while (cin >> n >> m) {
    v.clear();
    sum = 0;
    for (int i = 0; i <= n; i++) {
      a[i] = 0;
    }
    while (!q.empty()) {
      q.pop();
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x, &y);
      zx.l = n - y + 1;
      zx.r = x;
      zx.id = i;
      v.push_back(zx);
    }
    sort(v.begin(), v.end());
    num = 0;
    for (now = 1; now <= n; now++) {
      for (; num < v.size();) {
        if (v[num].l <= now) {
          t2.l = v[num].l;
          t2.r = v[num].r;
          t2.id = v[num].id;
          q.push(t2);
          num++;
        } else {
          break;
        }
      }
      while (!q.empty()) {
        if (q.top().r < now) {
          q.pop();
          continue;
        } else {
          a[now] = q.top().id;
          q.pop();
          sum++;
          break;
        }
      }
    }
    cout << sum << endl;
    temp = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i]) {
        if (temp) {
          printf(" ");
        }
        printf("%d", a[i]);
        temp = 1;
      }
    }
    cout << endl;
  }
  return 0;
}
