#include <bits/stdc++.h>
using namespace std;
struct data {
  int l, r, idx;
} lr[5005];
int cnt[5005];
bool cmp(data &a, data &b) {
  if (a.l == b.l) {
    return a.r < b.r;
  } else {
    return a.l < b.l;
  }
}
int main() {
  int n = 0;
  memset(cnt, 0, sizeof(cnt));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &lr[i].l, &lr[i].r);
    lr[i].idx = i + 1;
  }
  sort(lr, lr + n, cmp);
  map<int, set<int>> overlap;
  int must = 0, mustIdx = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (lr[j].l >= lr[i].r) {
        break;
      } else {
        overlap[i].insert(j);
        overlap[j].insert(i);
      }
    }
  }
  for (auto lap : overlap) {
    if (lap.second.size() > 1) {
      ++must;
      mustIdx = lap.first;
    }
    if (must > 1) {
      break;
    }
  }
  if (must > 1) {
    printf("0\n");
  } else if (must == 1) {
    for (auto lap : overlap[mustIdx]) {
      overlap[lap].erase(mustIdx);
      if (overlap[lap].empty()) {
        overlap.erase(lap);
      }
    }
    overlap.erase(mustIdx);
    if (overlap.empty()) {
      printf("1\n");
      printf("%d\n", lr[mustIdx].idx);
    } else {
      printf("0\n");
    }
  } else {
    if (overlap.empty()) {
      printf("%d\n", n);
      for (int i = 1; i <= n; ++i) {
        printf("%d ", i);
      }
      printf("\n");
    } else {
      if (overlap.size() > 2) {
        printf("0\n");
      } else {
        printf("2\n");
        set<int> res;
        for (auto lap : overlap) {
          res.insert(lr[lap.first].idx);
        }
        for (auto ans : res) {
          printf("%d ", ans);
        }
        printf("\n");
      }
    }
  }
  return 0;
}
