#include <bits/stdc++.h>
using namespace std;
struct cell {
  int r, c;
  int id;
};
bool operator<(const cell &a, const cell &b) {
  return a.r < b.r || (a.r == b.r && a.c < b.c);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<cell> f(m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &f[i].r, &f[i].c);
    f[i].id = i + 1;
  }
  sort(f.begin(), f.end());
  set<int> p;
  for (int i = 0; i < n; i++) p.insert(i);
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    int left_edge = n - f[i].c;
    int right_edge = f[i].r - 1;
    set<int>::iterator found_place = p.lower_bound(left_edge);
    if (found_place == p.end()) continue;
    if (*found_place <= right_edge) {
      p.erase(found_place);
      ans.push_back(f[i].id);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
