#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<long, long> &a, const pair<long, long> &b) {
  if (a.second < b.second)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long n;
  cin >> n;
  vector<pair<long, long>> vl, vg;
  map<pair<long, long>, long> ml, mg;
  long x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x < y) {
      vl.push_back(make_pair(x, y));
      ml[make_pair(x, y)] = i + 1;
    } else {
      vg.push_back(make_pair(y, x));
      mg[make_pair(y, x)] = i + 1;
    }
  }
  if (vl.size() > vg.size()) {
    sort(vl.begin(), vl.end(), comp);
    cout << vl.size() << endl;
    for (int i = vl.size() - 1; i >= 0; i--) cout << ml[vl[i]] << " ";
    cout << endl;
  } else {
    sort(vg.begin(), vg.end(), comp);
    cout << vg.size() << endl;
    for (int i = 0; i < vg.size(); i++) cout << mg[vg[i]] << " ";
    cout << endl;
  }
  return 0;
}
