#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long INF = 1e18;
bool comp1(pair<long long, pair<long long, long long> > a,
           pair<long long, pair<long long, long long> > b) {
  return a.second.first > b.second.first;
}
bool comp2(pair<long long, pair<long long, long long> > a,
           pair<long long, pair<long long, long long> > b) {
  return a.second.first < b.second.first;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<pair<long long, pair<long long, long long> > > asc, desc;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a < b)
      asc.push_back({a, {b, i + 1}});
    else
      desc.push_back({a, {b, i + 1}});
  }
  sort(asc.begin(), asc.end(), comp1);
  sort(desc.begin(), desc.end(), comp2);
  if (asc.size() < desc.size()) asc = desc;
  cout << asc.size() << '\n';
  for (long long i = 0; i < asc.size(); i++)
    cout << asc[i].second.second << ' ';
  cout << '\n';
  return 0;
}
