#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384633832795;
const double EPS = 1e-7;
pair<int, pair<int, int> > A[100100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n;) {
    scanf("%d %d", &A[i].first, &A[i].second.first);
    A[i].second.second = ++i;
  }
  sort(A, A + n);
  int cnt = 0, ok = 0;
  vector<int> V;
  for (int i = 0; i < n; i++, ok = 0) {
    pair<int, pair<int, int> > lst = !i ? A[1] : A[0];
    int j = !i ? 2 : 1;
    for (; j < n; j++) {
      if (i != j) ok |= (A[j].first < lst.second.first) ? 1 : 0, lst = A[j];
    }
    if (!ok) {
      cnt++;
      V.push_back(A[i].second.second);
    }
  }
  sort((V).begin(), (V).end());
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d ", 1 + V[i]);
  puts("");
}
