#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int n;
int l[N], r[N];
int deg[N];
int total;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if ((l[i] >= l[j] && l[i] < r[j]) || (r[i] > l[j] && r[i] <= r[j]) ||
          (l[j] >= l[i] && l[j] < r[i]) || (r[j] > l[i] && r[j] <= r[i])) {
        deg[i]++;
        deg[j]++;
        total += 2;
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (total - deg[i] * 2 == 0) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
