#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[5005], b[5005];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%d %d", &a[i].first, &a[i].second);
  vector<int> ans;
  for (int t = 0; t < (n); ++t) {
    int m = 0;
    for (int j = 0; j < (n); ++j)
      if (t != j) b[m++] = a[j];
    int last = -1, ok = 1;
    sort(b, b + m);
    for (int i = 0; i < (m); ++i) {
      if (last > b[i].first) {
        ok = false;
        break;
      }
      last = b[i].second;
    }
    if (ok) ans.push_back(t);
  }
  printf("%d\n", int((ans).size()));
  for (int i = 0; i < (int((ans).size())); ++i) printf("%d ", ans[i] + 1);
  puts("");
  return 0;
}
