#include <bits/stdc++.h>
using namespace std;
bool compare(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.first < b.first.first;
}
void sol() {
  vector<pair<pair<int, int>, int> > schedule;
  vector<int> ans_array;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    schedule.push_back(make_pair(make_pair(a, b), i + 1));
  }
  sort(schedule.begin(), schedule.end());
  int answer = 0;
  int end = 0;
  bool add = true;
  for (int i = 0; i < n; i++) {
    add = true;
    end = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        if (schedule[j].first.first < end) {
          add = false;
          break;
        }
        end = schedule[j].first.second;
      }
    }
    answer += add;
    if (add) ans_array.push_back(schedule[i].second);
  }
  cout << answer << endl;
  sort(ans_array.begin(), ans_array.end());
  for (int i = 0; i < ans_array.size(); i++) cout << ans_array[i] << " ";
  cout << endl;
}
int main() {
  sol();
  return 0;
}
