#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
bool icomp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.second.first < b.second.first;
}
bool dcomp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.second.first > b.second.first;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > incr, decr;
  int a, b;
  for (int i = 0; i < (n); i++) {
    cin >> a >> b;
    ((a < b) ? incr : decr).push_back(make_pair(i + 1, make_pair(a, b)));
  }
  auto &v = (((int)incr.size() > (int)decr.size()) ? incr : decr);
  auto &comp = (((int)incr.size() > (int)decr.size()) ? dcomp : icomp);
  sort(v.begin(), v.end(), comp);
  cout << (int)v.size() << endl;
  for (auto &x : v) cout << x.first << " ";
  return 0;
}
