#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int inf = 2e9 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-15;
vector<int> ans;
int n, x, y;
vector<pair<int, pair<int, int> > > v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x >> y;
    v.push_back(make_pair(x, make_pair(y, i)));
  }
  sort((v).begin(), (v).end());
  for (int i = 0; i < (v).size(); ++i) {
    bool ok = 1;
    int la = 0;
    for (int j = 1; j < (v).size(); ++j) {
      if (i == j) continue;
      if (v[la].second.first > v[j].first) {
        ok = 0;
        break;
      }
      la = j;
    }
    if (ok) {
      ans.push_back(v[i].second.second);
    }
  }
  sort((ans).begin(), (ans).end());
  cout << (ans).size() << "\n";
  for (int i : ans) cout << i << " ";
}
