#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 20;
vector<pair<int, int>> ve;
int n, num, numof;
set<int> gr;
vector<int> ans;
bool fo;
bool intr(int l1, int r1, int l2, int r2) {
  if (l1 > l2 && l1 < r2) return true;
  if (r1 > l2 && r1 < r2) return true;
  if (l1 == l2 && r1 <= r2) return true;
  if (r1 == r2 && l1 > l2) return true;
  if (l1 <= l2 && r1 > l2 && r1 < r2) return true;
  if (l1 <= l2 && r1 > l2 && r1 > r2) return true;
  return false;
}
vector<vector<int>> in(5010);
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    ve.push_back(make_pair(l, r));
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (intr(ve[i].first, ve[i].second, ve[j].first, ve[j].second)) {
        in[i].push_back(j);
        in[j].push_back(i);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    bool ok = true;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (in[j].size() == 1) {
        if (in[j][0] != i) {
          ok = false;
          break;
        }
      } else if (in[j].size() > 1) {
        ok = false;
        break;
      }
    }
    if (ok) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (auto x : ans) printf("%d ", x + 1);
  return 0;
}
