#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m;
long long a[N], vis[N];
vector<pair<long long, long long> > g(N);
vector<long long> v;
map<pair<long long, long long>, long long> mp;
int32_t main() {
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  long long count = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long p, q;
    cin >> g[i].first;
    cin >> g[i].second;
    mp.insert(make_pair(make_pair(g[i].first, g[i].second), i + 1));
  }
  sort(g.begin(), g.begin() + n);
  for (long long i = 0; i < n; i++) {
    long long count = 0;
    long long flag = 0;
    for (long long j = 0; j < n; j++) {
      if (j + 1 == i && j + 1 != n - 1) {
        if (g[j + 2].first >= g[j].second) count++;
        continue;
      }
      if (j != i && j + 1 != i) {
        if (g[j + 1].first >= g[j].second) count++;
        continue;
      } else {
        continue;
      }
    }
    if (count == n - 2) {
      ans++;
      long long o = g[i].first;
      long long y = g[i].second;
      long long m = mp[make_pair(o, y)];
      v.push_back(m);
    }
  }
  sort(v.begin(), v.end());
  cout << ans << endl;
  for (long long i = 0; i < ans; i++) {
    cout << v[i] << " ";
  }
}
