#include <bits/stdc++.h>
using namespace std;
int n, l[5000], r[5000];
bool intersect(int i, int j) { return l[i] < r[j] && l[j] < r[i]; }
void solve() {
  vector<pair<int, int> > edge, deg;
  set<int> connected;
  for (int i = 0; i < (int)(n); i++) deg.push_back(make_pair(0, i));
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(i); j++) {
      if (intersect(i, j)) {
        edge.push_back(make_pair(i, j));
        deg[i].first++;
        deg[j].first++;
        connected.insert(i);
        connected.insert(j);
      }
    }
  }
  if (edge.size() == 0) {
    cout << n << endl;
    for (int i = 0; i < (int)(n); i++) cout << i + 1 << " ";
    cout << endl;
  } else if (edge.size() == 1) {
    cout << 2 << endl;
    cout << edge[0].second + 1 << " " << edge[0].first + 1 << endl;
  } else {
    sort(deg.rbegin(), deg.rend());
    if (connected.size() == edge.size() + 1 && deg[1].first <= 1) {
      cout << 1 << endl;
      cout << deg[0].second + 1 << endl;
    } else
      cout << 0 << endl;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> l[i] >> r[i];
  solve();
  return 0;
}
