#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  pair<pair<int, int>, int> p[n];
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(make_pair(a, b), i + 1);
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (j != i && j + 1 != i) {
        if (p[j].first.second > p[j + 1].first.first) goto abc;
      } else if (j != i && j + 2 < n) {
        if (p[j].first.second > p[j + 2].first.first) goto abc;
      }
    }
    ans.push_back(p[i].second);
  abc:;
  }
  cout << ans.size() << endl;
  int answer[ans.size()];
  for (int i = 0; i < ans.size(); i++) {
    answer[i] = ans[i];
  }
  sort(answer, answer + ans.size());
  for (int i = 0; i < ans.size(); i++) cout << answer[i] << " ";
  return 0;
}
