#include <bits/stdc++.h>
using namespace std;
pair<long long, pair<long long, long long> > a[100010];
set<pair<long long, long long> > st;
set<pair<long long, long long> >::iterator it;
vector<long long> v;
int main() {
  long long n, m, i;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i].second.first >> a[i].first, a[i].second.second = i;
    a[i].second.first = n - a[i].second.first + 1;
  }
  sort(a + 1, a + 1 + m);
  long long l = n, r = m;
  for (i = n; i >= 1; i--) {
    while (r >= 1 && a[r].first >= i) {
      st.insert({-a[r].second.first, a[r].second.second});
      r--;
    }
    while (st.size() != 0 && -st.begin()->first > i) {
      st.erase(st.begin());
    }
    if (st.size() != 0) {
      v.push_back(st.begin()->second);
      st.erase(st.begin());
    }
  }
  cout << v.size() << '\n';
  for (i = 0; i < v.size(); i++) cout << v[i] << ' ';
}
