#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
pair<int, pair<int, int> > a[maxn];
int n, m;
int t[maxn << 2];
bool G[maxn];
bool cmp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.first != b.first ? a.first < b.first
                            : a.second.first < b.second.first;
}
bool get(int v, int l, int r, int L, int R) {
  if (l > R || r < L) return false;
  if (l == r) {
    if (t[v] == 0) return t[v] = 1;
    return 0;
  }
  int m = (l + r) >> 1;
  bool res = false;
  if (t[v << 1] < m - l + 1) {
    if (get(v << 1, l, m, L, R))
      res = true;
    else
      res = get(v << 1 | 1, m + 1, r, L, R);
  } else
    res = get(v << 1 | 1, m + 1, r, L, R);
  t[v] = t[v << 1] + t[v << 1 | 1];
  return res;
}
bool can(int x, int y) {
  y = n - y + 1;
  return get(1, 1, n, y, x);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0, x, y; i < m; i++) {
    scanf("%d %d", &x, &y);
    a[i] = {x, {y, i + 1}};
  }
  sort(a, a + m, cmp);
  int res = 0;
  for (int i = 0; i < m; i++)
    if (can(a[i].first, a[i].second.first)) G[a[i].second.second] = true;
  for (int i = 1; i <= m; i++) res += G[i];
  printf("%d\n", res);
  for (int i = 1; i <= m; i++)
    if (G[i]) printf("%d ", i);
  return 0;
}
