#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 50;
int r[N], l[N];
bool a[N][N];
vector<int> v;
bool e(int x, int y) {
  if (l[x] > l[y]) swap(x, y);
  if (r[x] <= l[y]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  long long cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      a[i][j] = e(i, j);
      cnt += a[i][j];
    }
  for (int i = 0; i < n; i++) a[i][i] = false;
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) sum += a[i][j] + a[j][i];
    sum -= a[i][i];
    if (sum + n == cnt) v.push_back(i + 1);
  }
  cout << v.size() << '\n';
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  return 0;
}
