#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > data(n);
  for (int i = 0; i < n; ++i)
    cin >> data[i].first >> data[i].second.first, data[i].second.second = i + 1;
  sort(data.begin(), data.end());
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    bool flag = true;
    int prev = -1;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (prev == -1) {
        prev = j;
        continue;
      }
      flag &= !(data[j].first < data[prev].second.first);
      prev = j;
    }
    if (flag) ans.push_back(data[i].second.second);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}
