#include <bits/stdc++.h>
using namespace std;
pair<int, int> lr[5010];
int inter[5050];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> lr[i].first >> lr[i].second;
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if ((lr[j].first > lr[i].first) && (lr[j].first < lr[i].second)) {
        inter[i]++;
        inter[j]++;
      } else if ((lr[j].second > lr[i].first) &&
                 (lr[j].second < lr[i].second)) {
        inter[i]++;
        inter[j]++;
      } else if ((lr[i].first > lr[j].first) && (lr[i].first < lr[j].second)) {
        inter[i]++;
        inter[j]++;
      } else if ((lr[i].second > lr[j].first) &&
                 (lr[i].second < lr[j].second)) {
        inter[i]++;
        inter[j]++;
      }
    }
  }
  int one = 0, two = 0;
  vector<int> num;
  num.clear();
  vector<int> one_pos;
  one_pos.clear();
  vector<int> two_pos;
  two_pos.clear();
  for (int i = 1; i <= n; i++) {
    if (inter[i] == 1) {
      one++;
      one_pos.push_back(i);
    }
    if (inter[i] >= 2) {
      two++;
      num.push_back(inter[i]);
      two_pos.push_back(i);
    }
  }
  if (two_pos.size() > 1) {
    printf("0\n");
    return 0;
  }
  if (two_pos.size() == 1) {
    if (num[0] == one)
      printf("1\n%d\n", two_pos[0]);
    else {
      printf("0\n");
    }
    return 0;
  }
  if (one == 2 && two == 0) {
    printf("2\n%d %d\n", one_pos[0], one_pos[1]);
    return 0;
  }
  if (one > 2) {
    printf("0\n");
    return 0;
  }
  if (one == 0 && two == 0) {
    printf("%d\n", n);
    for (int i = 1; i <= n; i++) {
      printf("%d ", i);
    }
    printf("\n");
    return 0;
  }
  printf("�������\n");
  return 0;
}
