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