#include <bits/stdc++.h>
using namespace std;
long long int ESP = 1e18;
long long int FCB = 1e9 + 7;
long long int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long int N = 5005;
long long int l[N], r[N];
vector<pair<long long int, long long int>> vv;
bool fly(long long int x, long long int y) {
  if (l[x] >= r[y]) return false;
  if (r[x] <= l[y]) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) cin >> l[i] >> r[i];
  for (long long int i = 1; i < n + 1; i++) {
    for (long long int j = 1; j < n + 1; j++) {
      if (i != j && fly(i, j)) vv.push_back(make_pair(i, j));
    }
  }
  map<long long int, long long int> mp;
  long long int zz = vv.size();
  for (long long int i = 0; i < zz; i++) {
    mp[vv[i].first]++;
    mp[vv[i].second]++;
  }
  vector<long long int> ans;
  for (long long int i = 1; i <= n; i++) {
    if (mp[i] == zz) ans.push_back(i);
  }
  long long int dd = ans.size();
  cout << dd << "\n";
  for (long long int i = 0; i < dd; i++) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}
