#include <bits/stdc++.h>
using namespace std;
int n;
int l[10000], r[100000], b[5001], c[5001], w = 0;
vector<int> v[10000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if ((r[i] > l[j] && r[i] < r[j]) || (l[i] > l[j] && l[i] < r[j]) ||
          (l[j] > l[i] && l[j] < r[i]) || (r[j] > l[i] && r[j] < r[i])) {
        v[i].push_back(j);
        b[i]++;
      }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) b[v[i][j]]--;
    for (int j = 1; j <= n; j++)
      if (j != i && b[j] > 0) goto g;
    w++;
    c[w] = i;
  g:
    for (int j = 0; j < v[i].size(); j++) b[v[i][j]]++;
  }
  cout << w << endl;
  for (int i = 1; i <= w; i++) cout << c[i] << " ";
  return 0;
}
