#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int s;
  int e;
} period;
int run() {
  int i, j;
  int N;
  vector<period> lessons;
  vector<vector<int> > intersects;
  cin >> N;
  lessons.resize(N);
  intersects.resize(N);
  for ((i) = (0); (i) < (int)(N); (i)++) cin >> lessons[i].s >> lessons[i].e;
  for ((i) = (0); (i) < (int)(N); (i)++) {
    for ((j) = (0); (j) < (int)(N); (j)++) {
      if (i == j) continue;
      if ((lessons[j].s < lessons[i].e && lessons[i].s < lessons[j].e) ||
          (lessons[i].s < lessons[j].e && lessons[j].s < lessons[i].e))
        intersects[i].push_back(j);
    }
  }
  int candidate = -1;
  int count = 0;
  for ((i) = (0); (i) < (int)(N); (i)++) {
    if (intersects[i].size() >= 2) {
      candidate = i;
      count++;
    }
  }
  vector<int> ans;
  bool match;
  if (count == 0) {
    for ((i) = (0); (i) < (int)(N); (i)++) {
      match = true;
      for ((j) = (0); (j) < (int)(N); (j)++) {
        if (i == j) continue;
        if (intersects[j].size() == 1 && intersects[j][0] != i) {
          match = false;
          break;
        }
        if (match == false) break;
      }
      if (match) ans.push_back(i);
    }
  } else if (count == 1) {
    match = true;
    for ((j) = (0); (j) < (int)(N); (j)++) {
      if (j == candidate) continue;
      if (intersects[j].size() == 1 && intersects[j][0] != candidate) {
        match = false;
        break;
      }
      if (match == false) break;
    }
    if (match) ans.push_back(candidate);
  } else {
  }
  cout << ans.size() << endl;
  for (vector<int>::iterator it = ans.begin(); it != ans.end(); it++)
    cout << *it + 1 << " ";
  cout << endl;
  return 0;
}
int main() {
  run();
  return 0;
}
