#include <bits/stdc++.h>
using namespace std;
int const lim = 1e5 + 10;
int const MLOG = 20;
vector<pair<int, int> > inp[lim + 3];
vector<int> ans;
vector<int> ind[lim + 3];
multiset<pair<int, int> > cur;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    v = n - v + 1;
    int val = u - v;
    inp[v].push_back(make_pair(u, i + 1));
  }
  for (int i = 1; i <= n; i++) sort(inp[i].begin(), inp[i].end());
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    if (inp[i].empty()) continue;
    cnt = max(i, cnt);
    int nxt = i + 1;
    while (nxt <= n && inp[nxt].empty()) nxt++;
    for (int j = 0; j < inp[i].size(); j++) cur.insert(inp[i][j]);
    while (cnt < nxt) {
      if (cur.empty()) {
        break;
      }
      int u = cur.begin()->first, ind = cur.begin()->second;
      cur.erase(cur.begin());
      if (cnt <= u) ans.push_back(ind), cnt++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
}
