#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 100005;
struct Position {
  int col, id;
  bool operator<(const Position& other) const { return col > other.col; }
};
int N, M;
vector<Position> columns[N_MAX];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int row;
    Position p;
    cin >> row >> p.col;
    row--;
    p.id = i;
    p.col--;
    columns[row].push_back(p);
  }
  int cur = 0;
  vector<int> answer;
  priority_queue<Position> pq;
  for (int i = N - 1; i >= 0; i--) {
    cur = max(cur, N - 1 - i);
    for (int j = 0; j < columns[i].size(); j++) pq.push(columns[i][j]);
    while (!pq.empty()) {
      Position next = pq.top();
      pq.pop();
      if (next.col < cur) continue;
      answer.push_back(next.id);
      cur++;
      if (cur + i >= N) break;
    }
  }
  cout << answer.size() << '\n';
  sort(answer.begin(), answer.end());
  for (int i = 0; i < answer.size(); i++)
    cout << answer[i] + 1 << (i == answer.size() - 1 ? "\n" : " ");
}
