#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n;
struct Node {
  int l, r;
  int id;
  bool operator<(const Node& u) const { return l < u.l; }
} node[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &node[i].l, &node[i].r);
    node[i].id = i;
  }
  sort(node, node + n);
  int a = -1, b = -1;
  bool flag = true;
  bool ww = false;
  int u = node[0].id;
  int hand = node[0].l, tail = node[0].r;
  for (int i = 1; i < n; i++) {
    if (node[i].l < tail) {
      if (ww == true) {
        flag = false;
        break;
      }
      ww = true;
      if (i == n - 1) {
        a = u;
        b = node[i].id;
      } else {
        int th = hand, tt = tail;
        int er, et, v;
        hand = node[i].l;
        tail = node[i].r;
        if (node[i + 1].l >= tail) {
          a = u;
          er = hand;
          et = tail;
          v = node[i].id;
        }
        hand = th;
        tail = tt;
        if (node[i + 1].l >= tail) {
          if (a != -1)
            b = node[i].id;
          else
            a = node[i].id;
          er = hand;
          et = tail;
          v = u;
        }
        if (a == -1 && b == -1) {
          flag = false;
          break;
        }
        hand = er;
        tail = et;
        u = v;
      }
      continue;
    }
    hand = node[i].l;
    tail = node[i].r;
    u = node[i].id;
  }
  if (flag == false)
    printf("0\n");
  else {
    int d = 0;
    if (a != -1) d++;
    if (b != -1) d++;
    if (d == 1)
      printf("%d\n%d\n", d, a + 1);
    else if (d == 2) {
      if (a > b) swap(a, b);
      printf("%d\n%d %d\n", d, a + 1, b + 1);
    } else {
      printf("%d\n", n);
      for (int i = 1; i <= n; i++) {
        if (i == n)
          printf("%d\n", i);
        else
          printf("%d ", i);
      }
    }
  }
  return 0;
}
