#include <bits/stdc++.h>
using namespace std;
bool comp1(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) {
    return true;
  }
  return false;
}
bool comp2(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return true;
  return false;
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int> > vp[2];
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      vp[0].push_back({a, i});
    } else {
      vp[1].push_back({a, i});
    }
  }
  sort(vp[0].begin(), vp[0].end(), comp1);
  sort(vp[1].begin(), vp[1].end(), comp2);
  if (vp[0].size() > vp[1].size()) {
    cout << vp[0].size() << endl;
    for (auto x : vp[0]) {
      cout << x.second + 1 << " ";
    }
  } else {
    cout << vp[1].size() << endl;
    for (auto x : vp[1]) {
      cout << x.second + 1 << " ";
    }
  }
}
int main() {
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
