#include<bits/stdc++.h> #define LOG 20 #define MAX_N 200000 #define INF 0x3f3f3f3f usingnamespace std; template <classT> inlinevoidread(T &x){ x = 0; int c = getchar(), f = 1; for (; !isdigit(c); c = getchar()) if (c == 45) f = -1; for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0'); } int n, m, L[MAX_N+5], R[MAX_N+5], nxt[MAX_N+5][LOG+1]; structnode {int l, r; booloperator < (const node &t) const;} a[MAX_N+5], b[MAX_N+5]; bool node::operator < (const node &t) const {return r == t.r ? l > t.l : r < t.r;} intcalc(int l, int r){ int u = lower_bound(L+1, L+m+1, l)-L, ret = 1; if (u > m || R[u] > r) return0; for (int i = LOG; ~i; i--) if (nxt[u][i] && R[nxt[u][i]] <= r) ret += 1<<i, u = nxt[u][i]; return ret; } intmain(){ read(n); set <node> s; for (int i = 1; i <= n; i++) read(a[i].l), read(a[i].r), b[i] = a[i]; sort(b+1, b+n+1), m = 0; for (int i = 1; i <= n; i++) if (b[i].l > b[m].l) b[++m] = b[i]; for (int i = 1; i <= m; i++) L[i] = b[i].l, R[i] = b[i].r; for (int i = 1, j = 1; i <= m; i++) { while (j <= m && b[j].l <= b[i].r) j++; if (j <= m) nxt[i][0] = j; } for (int i = 1; i <= LOG; i++) for (int j = 1; j <= m; j++) nxt[j][i] = nxt[nxt[j][i-1]][i-1]; s.insert((node){-INF, -INF}), s.insert((node){INF, INF}); printf("%d\n", calc(-INF, INF)); for (int i = 1; i <= n; i++) { set <node> :: iterator ln = s.lower_bound(a[i]), rn = ln; ln--; int l = a[i].l, r = a[i].r, lr = ln->r, rl = rn->l; if (l <= lr || r >= rl) continue; if (calc(lr+1, rl-1) == calc(lr+1, l-1)+calc(r+1, rl-1)+1) s.insert(a[i]), printf("%d ", i); } returnputs(""), 0; }