#include <bits/stdc++.h>
using namespace std;
FILE* in = stdin;
class node {
 public:
  int s, e, ind;
};
bool cmp(node a, node b) {
  if (a.s != b.s) return a.s < b.s;
  return a.e < b.e;
}
int n, ret[6000], retc;
node arr[6000];
bool check(int ind) {
  int i, a;
  for (i = 0; i < n; i++) {
    if (i == ind) continue;
    a = i + 1;
    if (a == ind) a++;
    if (a >= n) break;
    if (arr[i].e > arr[a].s) return 0;
  }
  return 1;
}
int main() {
  int i, a;
  fscanf(in, "%d", &n);
  for (i = 0; i < n; i++) {
    fscanf(in, "%d %d", &arr[i].s, &arr[i].e);
    arr[i].ind = i + 1;
  }
  sort(arr, arr + n, cmp);
  for (i = 0; i < n; i++)
    if (check(i)) ret[retc++] = arr[i].ind;
  sort(ret, ret + retc);
  printf("%d\n", retc);
  if (retc) {
    for (i = 0; i < retc - 1; i++) printf("%d ", ret[i]);
    printf("%d\n", ret[retc - 1]);
  }
  return 0;
}
