#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n;
vector<pair<int, int> > v;
const int N = 5005;
int mat[N];
int axx[N];
vector<int> g[N];
bool intersect(int a, int b) {
  if (v[a].first < v[b].first && v[a].second > v[b].first) return true;
  if (v[b].first < v[a].first && v[b].second > v[a].first) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  v.clear();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (intersect(i, j)) {
        mat[i]++;
        mat[j]++;
        axx[i]++;
        axx[j]++;
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < g[i].size(); ++j) {
      int y = g[i][j];
      mat[y]--;
    }
    mat[i] = 0;
    int nok = 0;
    for (int j = 0; j < n && !nok; ++j) nok = mat[j];
    memcpy(mat, axx, sizeof axx);
    if (nok) continue;
    ans.push_back(i + 1);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
