#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans[5000], sol = 0;
  pair<pair<int, int>, int> arr[5000];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.first >> arr[i].first.second;
    arr[i].second = i + 1;
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    int found = 0;
    for (int j = 0; j < n - 1; j++) {
      if ((j + 1) == i && j + 2 < n) {
        if (arr[j].first.second > arr[j + 2].first.first) {
          found = 1;
          break;
        }
        j++;
      } else if (j != i && (j + 1) != i) {
        if (arr[j].first.second > arr[j + 1].first.first) {
          found = 1;
          break;
        }
      }
    }
    if (found == 0) ans[sol++] = arr[i].second;
  }
  sort(ans, ans + sol);
  cout << sol << endl;
  for (int i = 0; i < sol; i++) cout << ans[i] << ' ';
  return 0;
}
