#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > AgB;
  vector<pair<long long int, long long int> > BgA;
  for (int i = 1; i <= n; i++) {
    long long int a, b;
    cin >> a >> b;
    if (a > b)
      AgB.push_back(make_pair(b, i));
    else
      BgA.push_back(make_pair(-b, i));
  }
  if (AgB.size() > BgA.size()) {
    cout << AgB.size() << endl;
    sort(AgB.begin(), AgB.end());
    for (int i = 0; i < AgB.size(); i++) cout << AgB[i].second << ' ';
  } else {
    cout << BgA.size() << endl;
    sort(BgA.begin(), BgA.end());
    for (int i = 0; i < BgA.size(); i++) cout << BgA[i].second << ' ';
  }
}
