#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
set<pair<pair<int, int>, int> > cnd;
vector<pair<pair<int, int>, int> > adj[M];
vector<int> res;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int r, c;
    cin >> r >> c;
    adj[r].push_back(make_pair(make_pair(c, r), i + 1));
  }
  for (vector<pair<pair<int, int>, int> >::iterator it = adj[n].begin();
       it != adj[n].end(); it++) {
    cnd.insert(*it);
  }
  for (int col = 1; col <= n; col++) {
    set<pair<pair<int, int>, int> >::iterator it1 = cnd.begin();
    if (it1 != cnd.end()) {
      res.push_back((*it1).second);
      cnd.erase(it1);
      for (set<pair<pair<int, int>, int> >::iterator it = cnd.begin();
           it != cnd.end();) {
        int icol = (*it).first.first;
        if (icol == col) {
          cnd.erase(it);
          it = cnd.begin();
        } else {
          break;
        }
      }
    }
    if (col < n) {
      for (vector<pair<pair<int, int>, int> >::iterator it =
               adj[n - col].begin();
           it != adj[n - col].end(); it++) {
        cnd.insert(*it);
      }
    }
  }
  int ans = res.size();
  cout << ans << endl;
  for (int i = 0; i < ans; i++) {
    printf("%d ", res[i]);
  }
  return 0;
}
