#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int x, y, id;
};
class mycomparison {
  bool reverse;

 public:
  mycomparison(const bool& revparam = false) { reverse = revparam; }
  bool operator()(const node& lhs, const node& rhs) const {
    if (lhs.x == rhs.x) {
      return lhs.y < rhs.y;
    } else
      return lhs.x > rhs.x;
  }
};
vector<node> v[100001] = {};
int main() {
  int n, m, r, c;
  node in;
  priority_queue<node, vector<node>, mycomparison> q;
  vector<int> ans;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> r >> c;
    in.x = c;
    in.y = n - r + 1;
    in.id = i + 1;
    v[in.y].push_back(in);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      q.push(v[i][j]);
    }
    while (!q.empty() && q.top().x < i) q.pop();
    if (!q.empty()) {
      ans.push_back(q.top().id);
      q.pop();
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  cout << endl;
}
