#include <bits/stdc++.h>
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
const int N = 5000;
const long M = 10000000;
const long long INF = 1000000000000000000;
int mod = 1 << 15;
int n, m, k, f, s, suc = true;
pair<pair<int, int>, int> a[N];
bool is_p(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) swap(a, b);
  if (a.second <= b.first)
    return false;
  else
    return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int index = 0, count = 0, suc = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].second = i;
  }
  sort(a, a + n);
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    bool suc = true;
    for (int j = 1; j < i; j++)
      if (a[j - 1].first.second > a[j].first.first) suc = false;
    if (i - 1 >= 0 && i + 1 < n && a[i - 1].first.second > a[i + 1].first.first)
      suc = false;
    for (int j = i + 2; j < n; j++)
      if (a[j - 1].first.second > a[j].first.first) suc = false;
    if (suc) ans.push_back(a[i].second + 1);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  return 0;
}
