#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct ky {
  int l, r, id;
  bool operator<(const ky &p) const { return l ^ p.l ? l < p.l : r < p.r; }
} a[N];
int ans[N], cnt, n;
inline void tj(register int id) {
  register int l = 0, r = 0;
  for (register int i = 1; i <= n; ++i) {
    if (i == id) continue;
    if (r > a[i].l) return;
    r = a[i].r > r ? a[i].r : r, l = a[i].l < l ? l : a[i].l;
  }
  ans[++cnt] = a[id].id;
}
inline void fr(int &num) {
  num = 0;
  char c = getchar();
  int p = 1;
  while (c < '0' || c > '9') c == '-' ? p = -1, c = getchar() : c = getchar();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar();
  num *= p;
}
int main() {
  fr(n);
  for (register int i = 1; i <= n; ++i) fr(a[i].l), fr(a[i].r), a[i].id = i;
  sort(a + 1, a + 1 + n);
  for (register int i = 1; i <= n; ++i) tj(i);
  printf("%d\n", cnt);
  sort(ans + 1, ans + 1 + cnt);
  for (register int i = 1; i <= cnt; ++i) printf("%d ", ans[i]);
  return 0;
}
