#include <bits/stdc++.h>
using namespace std;
struct node {
  int second, e;
  int indx;
  node(int a, int b, int c) : second(a), e(b), indx(c) { ; }
};
int N;
vector<node> vt;
set<int> res;
inline void in() {
  vt.clear();
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int second, e;
    scanf("%d", &second);
    scanf("%d", &e);
    vt.push_back(node(second, e, i + 1));
  }
  return;
}
inline bool cmp(node A, node B) { return (A.second < B.second); }
inline bool ntPossible(int s1, int s2) { return (s1 < s2); }
inline void doit() {
  res.clear();
  sort(vt.begin(), vt.end(), cmp);
  for (int i = 0; i < N; ++i) {
    int second = -1;
    bool possible = true;
    for (int j = 0; j < N; ++j) {
      if (i == j) continue;
      if (ntPossible(vt[j].second, second)) {
        possible = false;
        break;
      }
      second = vt[j].e;
    }
    if (possible) {
      res.insert(vt[i].indx);
    }
  }
  return;
}
inline void print() {
  cout << (int)(res).size() << "\n";
  for (typeof((res).begin()) it = (res).begin(); it != (res).end(); it++) {
    cout << (*it) << ' ';
  }
  return;
}
int main() {
  in();
  doit();
  print();
  return 0;
}
