#include <bits/stdc++.h>
using namespace std;
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int maxn = 100;
const int inf = 1 << 29;
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
struct NODE {
  int lf, rg, id;
  void read() { scanf("%d%d", &lf, &rg); }
} node[5100];
bool cmp(const NODE &a, const NODE &b) {
  if (a.lf < b.lf || a.lf == b.lf && a.rg < b.rg) return true;
  return false;
}
int c[5100], record[5100];
int n;
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) node[i].read(), node[i].id = i, c[i] = 0;
    sort(node + 1, node + 1 + n, cmp);
    for (int i = 2; i <= n; ++i) {
      for (int j = 1; j < i; ++j) {
        if (node[j].rg > node[i].lf || node[j].lf == node[i].lf) {
          ++c[j], ++c[i];
          record[j] = i, record[i] = j;
        }
      }
    }
    int tot = 0;
    int cnt = 0, num = 0, idx;
    for (int i = 1; i <= n; ++i) {
      if (c[i] >= 2) {
        ++tot;
        idx = i;
      }
    }
    if (tot > 1)
      puts("0");
    else if (tot == 1) {
      bool flag = true;
      for (int i = 1; i <= n; ++i)
        if (i != idx && c[i])
          if (record[i] != idx) {
            flag = false;
            break;
          }
      if (flag) {
        puts("1");
        printf("%d\n", node[idx].id);
      } else {
        puts("0");
      }
    } else {
      int pnum = 0, idx1 = -1, idx2 = -1;
      for (int i = 1; i <= n; ++i)
        if (c[i] && (node[i].id != idx1 && node[i].id != idx2)) {
          idx1 = node[i].id, idx2 = node[record[i]].id;
          ++pnum;
        }
      if (pnum == 0) {
        printf("%d\n", n);
        for (int i = 1; i <= n; ++i) printf("%d%c", i, i == n ? '\n' : ' ');
      } else if (pnum > 1)
        puts("0");
      else {
        printf("2\n");
        if (idx1 > idx2) swap(idx1, idx2);
        printf("%d %d\n", idx1, idx2);
      }
    }
  }
  return 0;
}
