#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool visit[100001];
const int mod = 1000000007;
struct node {
  int l, r, ind;
};
int cmp(node a, node b) {
  if (a.l > b.l) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i;
  cin >> n;
  vector<node> v;
  node temp;
  for (long long i = 0; i < n; i += 1) {
    cin >> temp.l >> temp.r;
    temp.ind = i + 1;
    v.push_back(temp);
  }
  sort(v.begin(), v.end(), cmp);
  vector<int> ans;
  for (long long i = 0; i < n; i += 1) {
    int f = 0;
    for (long long j = 1; j <= n - 1; j += 1) {
      if (j == i) continue;
      if (j == i + 1) {
        if (j == 1) continue;
        if (v[j].l < v[j - 2].r) {
          f = 1;
          break;
        }
      } else {
        if (v[j].l < v[j - 1].r) {
          f = 1;
          break;
        }
      }
    }
    if (!f) ans.push_back(v[i].ind);
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (long long i = 0; i < ans.size(); i += 1) cout << ans[i] << " ";
  return 0;
}
