#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979;
vector<pair<int, int> > A[100001];
int main() {
  int n, m, a, b;
  scanf("%d%d", &n, &m);
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  vector<int> ans;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    A[min(a, n + 1 - b)].push_back(make_pair(max(a, n + 1 - b), i + 1));
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < A[i].size(); ++j) {
      q.push(A[i][j]);
    }
    while (!q.empty()) {
      pair<int, int> t = q.top();
      if (t.first < i)
        q.pop();
      else
        break;
    }
    if (!q.empty()) {
      ans.push_back(q.top().second);
      q.pop();
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
