#include <bits/stdc++.h>
using namespace std;
int n, i, j, a, b;
vector<int> y[5001], path;
pair<int, int> p[5001];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if ((p[i].first >= p[j].first && p[j].second > p[i].first) ||
          (p[i].first <= p[j].first && p[i].second > p[j].first)) {
        y[i].push_back(j);
        y[j].push_back(i);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (y[i].size() > 1) {
      a++;
      b = i;
    }
    if (y[i].size() == 1) path.push_back(i);
  }
  if (a > 1) cout << 0;
  if (a == 1) {
    cout << 1 << endl;
    cout << b;
  }
  if (a == 0) {
    if (path.size() == 0) {
      cout << n << endl;
      for (i = 1; i <= n; i++) cout << i << " ";
    } else
      cout << path.size() << endl;
    for (i = 0; i < path.size(); i++) cout << path[i] << " ";
  }
  return 0;
}
