#include <bits/stdc++.h>
using namespace std;
int n;
pair<pair<int, int>, int> a[5050];
vector<int> Ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i].first.first >> a[i].first.second, a[i].second = i;
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    int Last = -1;
    bool check = true;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        if (a[j].first.first >= Last)
          Last = a[j].first.second;
        else
          check = false;
      }
    }
    if (check) Ans.push_back(a[i].second);
  }
  cout << Ans.size() << '\n';
  sort(Ans.begin(), Ans.end());
  for (auto x : Ans) cout << x + 1 << " ";
  return 0;
}
