#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > a;
vector<int> res;
int main() {
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < (n); ++i)
    cin >> a[i].first.second >> a[i].first.first, a[i].second = i + 1;
  sort((a).begin(), (a).end());
  for (int elim = 0; elim < (n); ++elim) {
    int last = -1;
    for (int i = 0; i < (n); ++i)
      if (i != elim) {
        if (last > a[i].first.second)
          goto C;
        else
          last = max(last, a[i].first.first);
      }
    res.push_back(a[elim].second);
  C:;
  }
  sort((res).begin(), (res).end());
  n = (int)(res).size();
  cout << n << endl;
  for (int i = 0; i < (n); ++i) cout << res[i] << (i + 1 == n ? '\n' : ' ');
  return 0;
}
