#include <bits/stdc++.h>
using namespace std;
int a[6000], b[6000];
vector<int> v[6000], s;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] < a[j] && a[j] < b[i]) {
        v[i].push_back(j);
        v[j].push_back(i);
      } else if (a[i] > a[j] && a[i] < b[j]) {
        v[i].push_back(j);
        v[j].push_back(i);
      } else if (a[i] == a[j] && b[i] < b[j]) {
        v[i].push_back(j);
        v[j].push_back(i);
      } else if (a[i] == a[j] && b[i] > b[j]) {
        v[i].push_back(j);
        v[j].push_back(i);
      } else if (b[i] == b[j] && a[i] < a[j]) {
        v[i].push_back(j);
        v[j].push_back(i);
      } else if (b[i] == b[j] && a[i] > a[j]) {
        v[i].push_back(j);
        v[j].push_back(i);
      }
    }
  }
  bool mark = false;
  for (int i = 1; i <= n; i++) {
    mark = false;
    for (int j = 1; j <= n; j++) {
      if (j != i) {
        if (v[j].size() == 0) {
          continue;
        }
        if (v[j].size() > 1) {
          mark = true;
          break;
        }
        if (v[j][0] != i) {
          mark = true;
          break;
        }
      }
    }
    if (mark == false) {
      s.push_back(i);
    }
  }
  cout << s.size() << endl;
  for (int i = 0; i < s.size(); i++) cout << s[i] << " ";
  return 0;
}
