#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> r(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i] >> r[i];
  }
  set<pair<int, int> > myset;
  set<pair<int, int> >::iterator it;
  for (int i = 0; i < n; ++i) {
    myset.insert(make_pair(2 * l[i] + 1, i));
    myset.insert(make_pair(2 * r[i], i));
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    it = myset.find(make_pair(2 * l[i] + 1, i));
    myset.erase(it);
    it = myset.find(make_pair(2 * r[i], i));
    myset.erase(it);
    int ind = -1;
    bool ok = true;
    for (it = myset.begin(); it != myset.end(); ++it) {
      int k = (*it).second;
      if (ind >= 0) {
        if (k != ind) {
          ok = false;
          break;
        }
        ind = -1;
      } else {
        ind = k;
      }
    }
    if (ok) ans.push_back(i + 1);
    myset.insert(make_pair(2 * l[i] + 1, i));
    myset.insert(make_pair(2 * r[i], i));
  }
  cout << ((int)ans.size()) << endl;
  for (int i = 0; i < ((int)ans.size()); ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
