#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, m;
struct Rec {
  int first, second, ind;
} a[100111];
bool operator<(const Rec &a, const Rec &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
int cnt[100111];
vector<int> res, res2;
inline int size(int l, int r) { return r - l + 1; }
int get(int x) {
  int res = 0;
  while (x > 0) {
    res += cnt[x];
    x -= ((x) & (-(x)));
  }
  return res;
}
void update(int x, int k) {
  while (x <= n) {
    cnt[x] += k;
    x += ((x) & (-(x)));
  }
}
int getFirst(int x) {
  int l = x, r = n;
  while (l <= r) {
    if (get(r) - get(l - 1) == size(l, r)) return n + 1;
    if (l == r) return l;
    int mid = (l + r) >> 1;
    if (get(mid) - get(l - 1) != size(l, mid)) {
      r = mid;
    } else
      l = mid + 1;
  }
  return n + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1), _b = (m); i <= _b; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    a[i].ind = i;
  }
  sort(a + 1, a + m + 1);
  for (int i = (1), _b = (m); i <= _b; i++) {
    int l = a[i].first;
    int r = n + 1 - a[i].second;
    if (l > r) swap(l, r);
    int x = getFirst(l);
    if (x <= r) {
      res.push_back(a[i].ind);
      update(x, 1);
    }
  }
  printf("%d\n", res.size());
  for (int x = 0, _a = (res.size()); x < _a; x++) printf("%d ", res[x]);
  return 0;
}
