#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  ;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  vector<pair<pair<int, int>, int>> ps;
  for (auto i = 0; i < n; i++) {
    int x;
    cin >> x;
    ;
    int y;
    cin >> y;
    ;
    ps.push_back({{x, y}, i});
  }
  sort(ps.begin(), ps.end());
  vector<int> ans;
  for (auto i = 0; i < n; i++) {
    int endd = -1;
    bool f = true;
    for (auto j = 0; j < n; j++) {
      if (ps[j].second == i) continue;
      if (ps[j].first.first < endd) {
        f = false;
        break;
      } else
        endd = ps[j].first.second;
    }
    if (f) ans.push_back(i + 1);
  }
  cout << ans.size() << endl;
  for (auto it : ans) cout << it << " ";
  return 0;
}
