#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b;
  vector<pair<long long, long long> > inc, dec;
  vector<long long> ind1, ind2;
  map<pair<long long, long long>, long long> mp;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a >> b;
    if (b - a > 0)
      inc.push_back({b, a});
    else
      dec.push_back({b, a});
    mp[{b, a}] = i + 1;
  }
  sort(inc.rbegin(), inc.rend());
  sort(dec.begin(), dec.end());
  if (inc.size() > 0) ind1.push_back(mp[{inc[0].first, inc[0].second}]);
  for (long long i = 1; i < inc.size(); i++) {
    if (inc[i].second < inc[i - 1].first) {
      ind1.push_back(mp[{inc[i].first, inc[i].second}]);
    } else
      break;
  }
  if (dec.size() > 0) ind2.push_back(mp[{dec[0].first, dec[0].second}]);
  for (long long i = 1; i < dec.size(); i++) {
    if (dec[i].second > dec[i - 1].first) {
      ind2.push_back(mp[{dec[i].first, dec[i].second}]);
    } else
      break;
  }
  if (ind1.size() > ind2.size()) {
    cout << ind1.size() << endl;
    for (long long i = 0; i < ind1.size(); i++) cout << ind1[i] << " ";
  } else {
    cout << ind2.size() << endl;
    for (long long i = 0; i < ind2.size(); i++) cout << ind2[i] << " ";
  }
}
