#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, k, x, y;
pair<int, int> now[N];
set<pair<int, int> > in[N], cur;
set<pair<int, int> >::iterator all;
vector<int> ans;
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    now[i] = make_pair(min(n - x + 1, y), max(n - x + 1, y));
    in[now[i].first].insert(make_pair(now[i].second, i));
  }
  sort(now + 1, now + m + 1);
  for (int i = 1; i <= n; ++i) {
    for (all = in[i].begin(); all != in[i].end(); ++all) cur.insert(*all);
    while ((*(cur.begin())).first < i && cur.size()) cur.erase(cur.begin());
    if (!cur.size()) continue;
    ans.push_back((cur.begin())->second);
    cur.erase(cur.begin());
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i = 0; i < (int)ans.size(); ++i) cout << ans[i] << " ";
}
