#include <bits/stdc++.h>
using namespace std;
int INP, AM, REACHEOF;
char BUF[(1 << 12) + 1], *inp = BUF;
const long double PI = acos((long double)-1.0);
const int MN = 2000111;
int n, m;
int f[MN], tr[MN], used[MN];
vector<int> ke[MN];
bool need[MN];
pair<int, int> seg[MN];
int color[MN];
int it[MN * 3];
void init() {
  for (int i = (1), _b = (n); i <= _b; i++) ke[i].clear();
  for (int i = (1), _b = (n); i <= _b; i++) f[i] = MN, tr[i] = -1, used[i] = 0;
  memset(need, false, sizeof need);
  memset(color, 0, sizeof color);
  memset(it, -1, sizeof it);
}
void paint() {
  for (int i = (1), _b = (m); i <= _b; i++) {
    color[seg[i].first]++;
    color[seg[i].second + 1]--;
  }
  for (int i = (1), _b = (n); i <= _b; i++) color[i] += color[i - 1];
}
int get(int i, int l, int r, int u, int v) {
  if (v < l || r < u) return -1;
  if (u <= l && r <= v) return it[i];
  int mid = (l + r) >> 1;
  int x = get(((i) << 1), l, mid, u, v);
  int y = get((((i) << 1) + 1), mid + 1, r, u, v);
  if (x < 0)
    return y;
  else if (y < 0)
    return x;
  else if (f[x] < f[y])
    return x;
  else
    return y;
}
void update(int i, int l, int r, int u) {
  if (u < l || r < u) return;
  if (l == r) {
    it[i] = u;
    return;
  }
  int mid = (l + r) >> 1;
  update(((i) << 1), l, mid, u);
  update((((i) << 1) + 1), mid + 1, r, u);
  if (it[i] < 0 || f[u] < f[it[i]]) it[i] = u;
}
void solve() {
  f[1] = 0;
  update(1, 1, n, 1);
  for (int i = (2), _b = (n); i <= _b; i++) {
    if (!color[i])
      f[i] = f[i - 1], tr[i] = i - 1, used[i] = 0;
    else {
      f[i] = 1000111;
      tr[i] = -1;
      for (int t = 0, _a = (ke[i].size()); t < _a; t++) {
        int seg_id = ke[i][t];
        int j = get(1, 1, n, seg[seg_id].first - 1, i - 1);
        if (j >= 0 && f[j] + 1 < f[i]) {
          f[i] = f[j] + 1;
          tr[i] = j;
          used[i] = seg_id;
        }
      }
    }
    update(1, 1, n, i);
  }
  int v = n;
  while (v > 0) {
    if (used[v]) need[used[v]] = true;
    v = tr[v];
  }
  printf("%d\n", m - f[n]);
  for (int i = (1), _b = (m); i <= _b; i++)
    if (!need[i]) printf("%d ", i);
  puts("");
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    init();
    ++n;
    for (int i = (1), _b = (m); i <= _b; i++) {
      int u, len;
      scanf("%d%d", &u, &len);
      int v = u + len - 1;
      ++u;
      ++v;
      ke[v].push_back(i);
      seg[i] = make_pair(u, v);
    }
    paint();
    solve();
  }
  return 0;
}
