#include <bits/stdc++.h>
using namespace std;
int l[55555], r[55555];
multiset<pair<int, int> > st;
multiset<pair<int, int> >::iterator it, t;
bool check() {
  for (it = st.begin(), t = ++st.begin(); it != st.end() && t != st.end();
       ++t, ++it)
    if (it->second > t->first) return 0;
  return 1;
}
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d%d", l + i, r + i), st.insert(make_pair(l[i], r[i]));
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    it = st.lower_bound(make_pair(l[i], r[i]));
    st.erase(it);
    if (check()) ans.push_back(i + 1);
    st.insert(make_pair(l[i], r[i]));
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}
