#include <bits/stdc++.h>
using namespace std;
struct Data {
  int begin;
  int end;
  int index;
  Data() {}
  Data(int a, int b) {
    begin = a;
    end = b;
  }
  bool operator<(Data d) const { return end < d.end; }
};
Data arr[5000];
bool Intersect(Data d1, Data d2) { return d1.end > d2.begin; }
bool test(int index, int N) {
  int last = -1;
  for (int n = 0; n < N; n++) {
    if (n == index) {
      continue;
    }
    if (last == -1) {
      last = n;
    } else {
      if (Intersect(arr[last], arr[n])) {
        return true;
      } else {
        last = n;
      }
    }
  }
  return false;
}
int main() {
  int N;
  scanf("%d", &N);
  for (int n = 0; n < N; n++) {
    scanf("%d %d", &arr[n].begin, &arr[n].end);
    arr[n].index = n + 1;
  }
  sort(arr, arr + N);
  set<int> pos;
  for (int n = 0; n < N - 1; n++) {
    if (Intersect(arr[n], arr[n + 1])) {
      pos.insert(n);
      pos.insert(n + 1);
    }
  }
  if (pos.size() == 0) {
    printf("%d\n", N);
    printf("1");
    for (int n = 1; n < N; n++) {
      printf(" %d", n + 1);
    }
    printf("\n");
  } else if (pos.size() > 3) {
    printf("0\n");
  } else {
    set<int> ret;
    for (set<int>::iterator it = pos.begin(); it != pos.end(); it++) {
      if (!test(*it, N)) {
        ret.insert(arr[*it].index);
      }
    }
    if (ret.size() == 0) {
      printf("0\n");
    } else {
      printf("%d\n", ret.size());
      set<int>::iterator it = ret.begin();
      printf("%d", *it);
      it++;
      while (it != ret.end()) {
        printf(" %d", *it);
        it++;
      }
      printf("\n");
    }
  }
}
