#include <bits/stdc++.h>
using namespace std;
pair<int, int> xx[5050];
int a[5050], n, res, k, i, j;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> xx[i].first >> xx[i].second;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (xx[i].first < xx[j].second && xx[i].second > xx[j].first) {
        a[i]++;
        a[j]++;
        res++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (a[i] == res) {
      k++;
    }
  }
  cout << k << endl;
  for (i = 0; i < n; i++) {
    if (a[i] == res) {
      cout << i + 1 << " ";
    }
  }
}
