#include <bits/stdc++.h>
using namespace std;
struct lesson {
  int groupid, start, finish;
  lesson() {}
  lesson(int gid, int st, int fin) : groupid(gid), start(st), finish(fin) {}
  bool operator<(const lesson &l) const {
    if (start != l.start)
      return start < l.start;
    else if (finish != l.finish)
      return finish < l.finish;
    else
      return groupid < l.groupid;
  }
};
int n;
vector<lesson> v;
bool intersect(lesson &a, lesson &b) {
  int l = max(a.start, b.start), r = min(a.finish, b.finish);
  return r - l > 0;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int ii = 1; ii <= n; ii++) {
    int a, b;
    cin >> a >> b;
    v.push_back(lesson(ii, a, b));
  }
  sort(v.begin(), v.end());
  set<int> ans;
  for (int idx = 0; idx < n; idx++) {
    lesson t = v[idx];
    int ptr = 1;
    bool ok = true;
    while (ptr < n) {
      if (ptr == idx)
        ptr++;
      else if (ptr == idx + 1) {
        if (idx > 0 && intersect(v[ptr], v[idx - 1])) ok = false;
        ptr++;
      } else {
        if (intersect(v[ptr], v[ptr - 1])) ok = false;
        ptr++;
      }
    }
    if (ok) ans.insert(t.groupid);
  }
  cout << ans.size() << endl;
  for (auto e : ans) cout << e << " ";
}
