#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int MOD = 1000000007;
struct Node {
  int x, y, id;
  Node() {}
  Node(int _x, int _y, int _i) {
    x = _x;
    y = _y;
    id = _i;
  }
  bool operator<(const Node &n) const { return x > n.x; }
};
int n, k;
vector<pair<int, int> > e[N];
vector<int> ans;
priority_queue<Node> que;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    y = n - y + 1;
    e[y].push_back(make_pair(x, i + 1));
  }
  for (int i = 1; i <= n; i++) {
    sort(e[i].begin(), e[i].end());
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < e[i].size(); j++)
      que.push(Node(e[i][j].first, i, e[i][j].second));
    while (!que.empty() && que.top().x < i) que.pop();
    if (!que.empty()) {
      ans.push_back(que.top().id);
      que.pop();
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
