#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const bool debug = true;
const long long INFL = LLONG_MAX;
int N, M;
vector<int> sportsmen[100100];
map<int, int> number[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cin >> N >> M;
  for (int(i) = 1; (i) <= (M); (i)++) {
    int r, c;
    cin >> r >> c;
    sportsmen[c].push_back(r);
    number[r][c] = i;
  }
  priority_queue<pair<int, int> > pq;
  vector<int> ans;
  for (int col = N; col >= 1; col--) {
    for (int i = 0; i < sportsmen[col].size(); i++) {
      int row = sportsmen[col][i];
      pq.push(make_pair(-row, -col));
    }
    while (!pq.empty()) {
      int r = -pq.top().first;
      int c = -pq.top().second;
      pq.pop();
      if (c > col && r < (N - col + 1)) {
        continue;
      } else {
        ans.push_back(number[r][c]);
        break;
      }
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int(i) = 0; (i) < (ans.size()); (i)++)
    cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
}
