#include <bits/stdc++.h>
using namespace std;
bool check(const vector<pair<pair<int, int>, int> >& vp, int ignore) {
  int lastFinish = -1;
  for (int i = 0; i < vp.size(); ++i) {
    if (i == ignore) continue;
    if (vp[i].first.first < lastFinish) return false;
    lastFinish = vp[i].first.second;
  }
  return true;
}
int main() {
  int N;
  cin >> N;
  vector<pair<pair<int, int>, int> > vp(N);
  for (int i = 0; i < N; ++i) {
    cin >> vp[i].first.first >> vp[i].first.second;
    vp[i].second = i + 1;
  }
  sort(vp.begin(), vp.end());
  vector<int> ret;
  for (int i = 0; i < N; ++i) {
    if (check(vp, i)) ret.push_back(vp[i].second);
  }
  sort(ret.begin(), ret.end());
  cout << ret.size() << endl;
  if (ret.size()) {
    for (int i = 0; i < ret.size(); ++i) {
      if (i) cout << ' ';
      cout << ret[i];
    }
    cout << endl;
  }
}
