#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, pair<int, int>>> keep;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    keep.push_back({b, {a, i + 1}});
  }
  sort((keep).begin(), (keep).end());
  int count = 0;
  int ind;
  int prev = -1;
  vector<int> group;
  for (int i = 0; i < n; i++) {
    if (keep[i].second.first >= prev) {
      prev = keep[i].first;
      continue;
    }
    group.push_back(keep[i].second.second);
    ind = i;
  }
  if (group.size() == 0) {
    cout << n << endl;
    for (int i = 1; i <= n; i++) {
      cout << i << " ";
    }
    cout << endl;
    return 0;
  }
  if (group.size() == 1) {
    if (keep[ind].second.first >= keep[ind - 2].first) {
      cout << 2 << endl;
      if (keep[ind - 1].second.second < keep[ind].second.second) {
        cout << keep[ind - 1].second.second << " " << keep[ind].second.second
             << endl;
      } else {
        cout << keep[ind].second.second << " " << keep[ind - 1].second.second
             << endl;
      }
      return 0;
    }
    cout << 1 << endl;
    cout << group[0] << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}
