#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int INF = 1e6;
int n, m;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int i, j, t, k, x, y, z, N;
  cin >> n;
  vector<int> ways;
  vector<tuple<int, int, int>> grp(n);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    grp[i] = make_tuple(x, y, i + 1);
  }
  sort(grp.begin(), grp.end());
  for (i = 0; i < n; i++) {
    int flag = 0;
    for (j = 0; j < n; j++) {
      if (j != i) {
        if (j > 0) {
          if (j - 1 != i) {
            if (get<1>(grp[j - 1]) > get<0>(grp[j])) flag = 1;
          } else {
            if (j - 1 > 0) {
              if (get<1>(grp[j - 2]) > get<0>(grp[j])) flag = 1;
            }
          }
        }
      }
    }
    if (flag == 0) {
      ways.push_back(get<2>(grp[i]));
    }
  }
  sort(ways.begin(), ways.end());
  cout << ways.size() << '\n';
  for (int i = 0; i < ways.size(); i++) cout << ways[i] << " ";
  return 0;
}
