#include <bits/stdc++.h>
using namespace std;
bool more_than1(const vector<int>& a) { return a.size() > 1; }
bool not_zero(const vector<int>& a) { return a.size(); }
int main() {
  int n;
  cin >> n;
  vector<vector<int> > cnt(n);
  vector<pair<pair<int, bool>, int> > sob;
  sob.reserve(2 * n);
  for (int i = 0; i < (n); ++i) {
    int a, b;
    cin >> a >> b;
    sob.push_back(make_pair(make_pair(a, true), i));
    sob.push_back(make_pair(make_pair(b, false), i));
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(sob.begin(), sob.end());
  set<int> open;
  for (int i = 0; i < (sob.size()); ++i) {
    if (!sob[i].first.second) {
      open.erase(sob[i].second);
    } else {
      set<int>::iterator it;
      for (it = open.begin(); it != open.end(); ++it) {
        cnt[*it].push_back(sob[i].second);
        cnt[sob[i].second].push_back(*it);
      }
      open.insert(sob[i].second);
    }
  }
  if (count_if(cnt.begin(), cnt.end(), more_than1) > 1) {
    cout << 0 << endl;
    return 0;
  } else if (!count_if(cnt.begin(), cnt.end(), not_zero)) {
    cout << n << endl;
    for (int i = 1; i <= (n); ++i) cout << i << ' ';
    cout << endl;
    return 0;
  }
  vector<int> intersect;
  intersect.reserve(n);
  for (int i = 0; i < (n); ++i) {
    if (!cnt[i].empty()) {
      intersect.push_back(i);
    }
  }
  vector<int> res;
  for (int i = 0; i < (n); ++i) {
    if (cnt[i].size() == intersect.size() - 1) {
      res.push_back(i + 1);
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << endl;
  for (int i = 0; i < (res.size()); ++i) {
    cout << res[i] << ' ';
    if (i == res.size() - 1) cout << endl;
  }
}
