#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
           ? EOF
           : *p1++);
  bool flg = false;
  for (; ch < '0' || '9' < ch;
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
const int MAXN = 2e6 + 10;
int n, m, mnval[MAXN], tid[MAXN];
struct Segment_Tree {
  struct Node {
    int mn;
    long long add;
  } t[MAXN << 2];
  void pushup(int k) { t[k].mn = min(t[k << 1].mn, t[k << 1 | 1].mn); }
  void pushdown(int k) {
    long long& d = t[k].add;
    t[k << 1].mn += d, t[k << 1 | 1].mn += d;
    t[k << 1].add += d, t[k << 1 | 1].add += d;
    d = 0;
  }
  void modify(int k, int l, int r, int ql, int qr, int val) {
    if (ql <= l && r <= qr) return t[k].add += val, t[k].mn += val, void();
    pushdown(k);
    if (ql <= ((l + r) >> 1)) modify(k << 1, l, ((l + r) >> 1), ql, qr, val);
    if (qr > ((l + r) >> 1))
      modify(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr, val);
    pushup(k);
  }
  long long query(int k, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return t[k].mn;
    pushdown(k);
    long long res = INT_MAX;
    if (ql <= ((l + r) >> 1))
      res = min(res, query(k << 1, l, ((l + r) >> 1), ql, qr));
    if (qr > ((l + r) >> 1))
      res = min(res, query(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr));
    return res;
  }
} sgt;
int main() {
  IO::read(n), IO::read(m);
  vector<pair<int, int> > vec;
  for (int i = (1), iend = (m); i <= iend; ++i) {
    int l, r;
    IO::read(l), IO::read(r);
    vec.push_back(make_pair(l, l + r - 1));
  }
  iota(tid + 1, tid + m + 1, 1);
  sort(tid + 1, tid + m + 1, [&vec](const int x, const int y) {
    return vec[x - 1].first < vec[y - 1].first ||
           (vec[x - 1].first == vec[y - 1].first &&
            vec[x - 1].second > vec[y - 1].second);
  });
  stack<int> stk;
  int idx = 0;
  vector<int> ans, v;
  for (int i = (1), iend = (m); i <= iend; ++i) {
    if (!stk.empty() && vec[tid[i] - 1].second <= vec[stk.top()].second)
      ans.push_back(tid[i]);
    else
      stk.push(tid[i] - 1);
  }
  while (!stk.empty()) v.push_back(stk.top()), stk.pop();
  for (auto cur : v) sgt.modify(1, 1, n, vec[cur].first, vec[cur].second, 1);
  for (int i = (0), iend = (v.size() - 1); i <= iend; ++i) {
    mnval[i + 1] = sgt.query(1, 1, n, vec[v[i]].first, vec[v[i]].second);
  }
  iota(tid + 1, tid + v.size() + 1, 1);
  sort(tid + 1, tid + v.size() + 1,
       [](const int& x, const int& y) { return mnval[x] > mnval[y]; });
  for (int i = (0), iend = (v.size() - 1); i <= iend; ++i) {
    if (sgt.query(1, 1, n, vec[v[i]].first, vec[v[i]].second) > 1) {
      ans.push_back(v[i] + 1);
      sgt.modify(1, 1, n, vec[v[i]].first, vec[v[i]].second, -1);
    }
  }
  IO::write(ans.size(), '\n');
  for (int cur : ans) IO::write(cur);
  return 0;
}
