#include <bits/stdc++.h>   using namespace std;   int tree[100010 << 2];   bool flag;   struct node {     int row, col, pos;     friend bool operator<(node a, node b) {       if (a.row == b.row) return a.col < b.col;       return a.row < b.row;     }   };   node p[100010];   inline void pushUp(int rt) { tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]); }   void update(int x, int y, int val, int L, int R, int rt) {     if (flag) return;     if (L == R) {       if (tree[rt] == 0) {         flag = true;         tree[rt] = val;       }       return;     } else if (x <= L && R <= y) {       int mid = (L + R) >> 1;       if (tree[rt << 1] == 0)         update(x, y, val, L, mid, rt << 1);       else if (tree[rt << 1 | 1] == 0)         update(x, y, val, mid + 1, R, rt << 1 | 1);     } else {       int mid = (L + R) >> 1;       if (x <= mid) update(x, y, val, L, mid, rt << 1);       if (y > mid) update(x, y, val, mid + 1, R, rt << 1 | 1);     }     pushUp(rt);   }   void out(int L, int R, int rt) {     if (L == R) {       if (tree[rt]) printf( %d  , tree[rt]);     } else {       int mid = (L + R) >> 1;       out(L, mid, rt << 1);       out(mid + 1, R, rt << 1 | 1);     }   }   int main() {     int i;     int n, m, cnt;     while (~scanf( %d%d , &n, &m)) {       memset(tree, 0, sizeof(tree));       for (i = 0; i < m; i++) {         scanf( %d%d , &p[i].row, &p[i].col);         p[i].pos = i + 1;       }       sort(p, p + m);       for (cnt = i = 0; i < m; i++) {         flag = false;         update(n - p[i].col + 1, p[i].row, p[i].pos, 1, n, 1);         if (flag) cnt++;       }       printf( %d n , cnt);       out(1, n, 1);       putchar(  n );     }     return 0;   }   