#include <bits/stdc++.h>
using namespace std;
int l[5005], r[5005], s, sum[5005];
int n;
vector<int> ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    sum[i] = 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      if (l[i] < r[j] && l[j] < r[i]) {
        sum[i]++;
        sum[j]++;
        s++;
      }
    }
  for (int i = 0; i < n; i++)
    if (sum[i] == s) ans.push_back(i + 1);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
