#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 69;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
long long m, n, k, q;
long long l;
long long x, y, z;
struct vl {
  long long x, y, z;
  bool operator<(vl t) const {
    if (x == t.x && y == t.y) return z < t.z;
    if (x == t.x) return y < t.y;
    return x < t.x;
  }
};
long long luythua(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x % mod;
  long long k = luythua(x, y / 2);
  if (y % 2 == 0) return k * k % mod;
  return k * k % mod * x % mod;
}
vl a[MAXN];
long long check[MAXN];
set<long long> s;
vector<long long> ans;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> a[i].x >> a[i].y;
    a[i].z = i;
    a[i].y = n + 1 - a[i].y;
  }
  sort(a + 1, a + m + 1);
  for (long long i = 1; i <= n; i++) s.insert(i);
  for (long long i = 1; i <= m; i++) {
    set<long long>::iterator itr = s.lower_bound(a[i].y);
    if (itr == s.end()) continue;
    if (*itr > a[i].x) continue;
    ans.push_back(a[i].z);
    s.erase(itr);
  }
  cout << ans.size() << '\n';
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i] << ' ';
  }
}
