#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long int mod = 1e9 + 7;
vector<pair<pair<long int, long int>, long int>> a;
long int i, j, n, m, k, l, t;
vector<long int> b;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long int i = 0; i < n; i++) {
    cin >> j >> k;
    pair<long int, long int> c = make_pair(j, k);
    a.push_back(make_pair(c, i));
  }
  sort(a.begin(), a.end());
  for (long int i = 0; i < n; i++) {
    int flag = 0;
    for (long int j = 0; j < n - 1; j++) {
      if (a[j].second == a[i].second || a[j + 1].second == a[i].second) {
        if (a[j + 1].second == a[i].second) {
          if ((j + 2) < n) {
            if (a[j].first.second > a[j + 2].first.first) {
              flag = 1;
              break;
            }
            j++;
          }
        } else
          continue;
      } else {
        if (a[j].first.second > a[j + 1].first.first) {
          flag = 1;
          break;
        }
      }
    }
    if (!flag) b.push_back(a[i].second + 1);
  }
  cout << b.size() << '\n';
  sort(b.begin(), b.end());
  for (long int i = 0; i < b.size(); i++) cout << b[i] << " ";
  return 0;
}
