#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long MAX = 2005;
int arr[MAX];
vector<pair<pair<int, int>, int> > v;
priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >,
               greater<pair<pair<int, int>, int> > >
    pq;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v.push_back(make_pair(make_pair(n + 1 - a, b), i));
  }
  sort(v.begin(), v.end());
  vector<int> ans;
  int curr = 0;
  for (int i = 1; i < n + 1; i++) {
    while (curr < v.size() && v[curr].first.first == i) {
      pq.push(make_pair(make_pair(v[curr].first.second, v[curr].first.first),
                        v[curr].second));
      curr++;
    }
    bool ok = true;
    while (ok && !pq.empty()) {
      pair<pair<int, int>, int> topx = pq.top();
      pq.pop();
      if (i <= topx.first.first) {
        ok = false;
        ans.push_back(topx.second);
      }
    }
  }
  cout << ans.size() << endl;
  for (int i : ans) {
    cout << i + 1 << " ";
  }
}
