#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
using namespace std;
pair<pair<int, int>, int> g[111111];
set<int> st;
vector<int> ans;
int main() {
  int i, n, m;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) st.insert(i);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &g[i].first.second, &g[i].first.first);
    g[i].second = i;
  }
  sort(g + 1, g + 1 + m);
  for (i = 1; i <= m; ++i) {
    if (st.empty()) continue;
    auto p = g[i];
    int x = p.first.second, y = p.first.first;
    auto iter = st.lower_bound(n + 1 - x);
    if (iter != st.end() && *iter <= y) {
      ans.push_back(p.second);
      st.erase(*iter);
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto p : ans) {
    printf("%d ", p);
  }
  printf("\n");
  return 0;
}
