#include <bits/stdc++.h>
using namespace std;
int b[2000008], can[2000008], pre[2000008], lst[2000008], f[2000008],
    vis[2000008];
struct question {
  int l, r, id;
} a[200008];
struct node {
  int l, r, ls, rs, w, id;
};
struct segtree {
  node tr[2000008 * 4];
  void up(int rt) {
    if (tr[tr[rt].ls].w <= tr[tr[rt].rs].w) {
      tr[rt].w = tr[tr[rt].ls].w;
      tr[rt].id = tr[tr[rt].ls].id;
    } else {
      tr[rt].w = tr[tr[rt].rs].w;
      tr[rt].id = tr[tr[rt].rs].id;
    }
  }
  void mk(int rt) {
    int l = tr[rt].l, r = tr[rt].r, m = (l + r) >> 1;
    if (l == r) {
      tr[rt].w = 0;
      tr[rt].id = l;
      return;
    }
    tr[rt].ls = rt << 1;
    tr[tr[rt].ls].l = l;
    tr[tr[rt].ls].r = m;
    mk(tr[rt].ls);
    tr[rt].rs = rt << 1 | 1;
    tr[tr[rt].rs].l = m + 1;
    tr[tr[rt].rs].r = r;
    mk(tr[rt].rs);
    up(rt);
  }
  void updt(int a, int b, int rt) {
    int l = tr[rt].l, r = tr[rt].r, m = (l + r) >> 1;
    if (l == r) {
      tr[rt].w = b;
      return;
    }
    if (a <= m)
      updt(a, b, tr[rt].ls);
    else
      updt(a, b, tr[rt].rs);
    up(rt);
  }
  int que(int a, int b, int& c, int rt) {
    int x, y, k, l = tr[rt].l, r = tr[rt].r, m = (l + r) >> 1, ans = 1e9;
    if (a <= l && b >= r) {
      c = tr[rt].id;
      return tr[rt].w;
    }
    if (a <= m) {
      k = que(a, b, x, tr[rt].ls);
      if (ans > k) {
        ans = k;
        c = x;
      }
    }
    if (b > m) {
      k = que(a, b, y, tr[rt].rs);
      if (ans > k) {
        ans = k;
        c = y;
      }
    }
    return ans;
  }
} tree;
bool cmp(question a, question b) { return (a.r ^ b.r) ? a.r < b.r : a.l < b.l; }
int main() {
  int i, j, k, x, n, m, sum;
  scanf("%d %d", &n, &m);
  tree.tr[1].l = 0;
  tree.tr[1].r = n;
  tree.mk(1);
  for (i = 1; i <= n; ++i) pre[i] = n + 1;
  for (i = 1; i <= m; ++i) {
    a[i].id = i;
    scanf("%d %d", &a[i].l, &a[i].r);
    a[i].r = a[i].l + a[i].r - 1;
    ++b[a[i].l];
    --b[a[i].r + 1];
    if (pre[a[i].r] > a[i].l) pre[a[i].r] = a[i].l;
  }
  sum = 0;
  for (i = 1; i <= n; ++i) {
    sum += b[i];
    can[i] = (sum ? 1 : 0);
  }
  sort(a + 1, a + m + 1, cmp);
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  tree.updt(0, f[0], 1);
  for (i = 1; i <= n; ++i) {
    if (can[i]) {
      if (pre[i] != n + 1) {
        k = tree.que(pre[i] - 1, i - 1, x, 1) + 1;
        f[i] = k;
        lst[i] = x;
      }
    } else {
      f[i] = f[i - 1];
      lst[i] = i - 1;
    }
    tree.updt(i, f[i], 1);
  }
  printf("%d\n", m - f[n]);
  j = m;
  for (i = n; i; i = lst[i]) {
    if (!can[i]) continue;
    while (a[j].r > i) --j;
    while (a[j].l > lst[i] + 1) --j;
    vis[a[j].id] = 1;
  }
  for (i = 1; i <= m; ++i)
    if (!vis[i]) printf("%d ", i);
  return 0;
}
