#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, m;
pair<pair<int, int>, int> a[N];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n >> m;
  for (int i = (1); i < (m + 1); i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(make_pair(n + 1 - y, x), i);
  }
  sort(a + 1, a + 1 + m);
  priority_queue<pair<int, int> > q;
  int p = 1;
  vector<int> ans;
  for (int i = (1); i < (n + 1); i++) {
    while (p <= m && a[p].first.first <= i)
      q.push(make_pair(-a[p].first.second, a[p].second)), ++p;
    while (!q.empty()) {
      pair<int, int> u = q.top();
      q.pop();
      if (-u.first >= i) {
        ans.push_back(u.second);
        break;
      }
    }
  }
  cout << (int)ans.size() << "\n";
  for (int i = (0); i < ((int)ans.size()); i++) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}
