#include <bits/stdc++.h>
using namespace std;
typedef struct T {
  int ind;
  int st;
  int ds;
  bool operator<(const T &one) const {
    if (st != one.st) return st < one.st;
    return ds < one.ds;
  }
} gr;
gr grps[10000];
int n;
vector<int> mv;
int valid(int nt) {
  int en = 0;
  for (int i = 0; i < n; i++) {
    if (i == nt) continue;
    if (grps[i].st < en) return 0;
    en = max(en, grps[i].ds);
  }
  return 1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> grps[i].st;
    cin >> grps[i].ds;
    grps[i].ind = i + 1;
  }
  sort(grps, grps + n);
  for (int i = 0; i < n; i++) {
    if (valid(i) == 1) mv.push_back(grps[i].ind);
  }
  cout << mv.size() << endl;
  sort(mv.begin(), mv.end());
  for (int i = 0; i < mv.size(); i++) cout << mv[i] << " ";
  return 0;
}
