#include <bits/stdc++.h>
using namespace std;
bool vis[100001];
int n, m;
int fi[100001], se[100001];
vector<int> qu[100001];
struct MY {
  bool operator()(const int &x, const int &y) {
    return se[x] != se[y] ? se[x] < se[y] : x < y;
  }
};
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    fi[i] = n - x + 1;
    se[i] = y;
    qu[fi[i]].push_back(i);
    qu[se[i] + 1].push_back(i);
  }
  set<int, MY> SET;
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < qu[i].size(); j++) {
      int x = qu[i][j];
      if (vis[x])
        SET.erase(x);
      else
        SET.insert(x);
      vis[x] = true;
    }
    if (!SET.empty()) {
      ans.push_back(*SET.begin());
      SET.erase(SET.begin());
    }
  }
  printf("%u\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
