#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
vector<pair<int, int> > u[N];
vector<int> ans;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  int i, j;
  for (i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    u[n + 1 - x].push_back(make_pair(y, i + 1));
  }
  priority_queue<pair<int, int> > pq;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < u[i].size(); j++)
      pq.push(make_pair(-u[i][j].first, -u[i][j].second));
    while (!pq.empty() && -pq.top().first < i) pq.pop();
    if (!pq.empty()) {
      ans.push_back(-pq.top().second);
      pq.pop();
    }
  }
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size() - 1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[i]);
}
