#include <bits/stdc++.h>
using namespace std;
struct xy {
  int x, y, p;
};
xy v[5048];
int sol[5048];
int n;
struct comp {
  bool operator()(const xy& a, const xy& b) {
    if (a.y == b.y) return a.x < b.x;
    return a.y < b.y;
  }
};
int valid_dreapta(int x) {
  for (int i = x; i < n; ++i)
    if (v[i].y > v[i + 1].x) return 0;
  return 1;
}
int valid_stanga(int n) {
  for (int i = 1; i < n; ++i)
    if (v[i].y > v[i + 1].x) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &v[i].x, &v[i].y);
    v[i].p = i;
  }
  sort(v + 1, v + n + 1, comp());
  v[n + 1].x = 2000000000;
  for (int i = 1; i <= n; ++i)
    if (valid_dreapta(i + 1) && valid_stanga(i - 1) && v[i - 1].y <= v[i + 1].x)
      sol[++sol[0]] = v[i].p;
  printf("%d\n", sol[0]);
  sort(sol + 1, sol + sol[0] + 1);
  for (int i = 1; i <= sol[0]; ++i) printf("%d ", sol[i]);
  return 0;
}
