#include <bits/stdc++.h>
using namespace std;
int a;
pair<pair<int, int>, int> b[5002];
int main() {
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) {
    scanf("%d %d", &b[i].first.first, &b[i].first.second);
    b[i].second = i;
  }
  sort(b + 1, b + a + 1);
  vector<int> vec;
  for (int i = 1; i <= a; i++) {
    int last = 0, bentrok = 0;
    for (int j = 1; j <= a; j++) {
      if (i == j) continue;
      if (last > b[j].first.first) {
        bentrok++;
        break;
      }
      last = b[j].first.second;
    }
    if (!bentrok) vec.push_back(b[i].second);
  }
  sort(vec.begin(), vec.end());
  printf("%d\n", vec.size());
  for (int i = 0; i < vec.size(); i++) {
    if (i) printf(" ");
    printf("%d", vec[i]);
  }
  if (vec.size()) printf("\n");
  return 0;
}
