#include <bits/stdc++.h>
using namespace std;
int n, l[5500], r[5500], p, res;
struct pp {
  int l, r, n;
};
bool cmp(pp a, pp b) { return a.l < b.l; }
int main() {
  cin >> n;
  vector<int> ans;
  vector<pp> v(n);
  for (int i = 0; i < n; i++) cin >> v[i].l >> v[i].r, v[i].n = i + 1;
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < n; i++) {
    p = 0;
    for (int j = 1; j < n; j++) {
      int prev = j - 1;
      if (j == i + 1)
        if (j > 1)
          prev = j - 2;
        else
          continue;
      if (j != i)
        if (v[j].l < v[prev].r) p = 1;
    }
    if (!p) res++, ans.push_back(v[i].n);
  }
  sort(ans.begin(), ans.end());
  cout << res << "\n";
  for (int i = 0; i < res; i++) cout << ans[i] << " ";
  return 0;
}
