#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }
bool compd1(pair<int, int> x, pair<int, int> y) { return x.first < y.first; }
int main() {
  int n;
  cin >> n;
  int a[n], b[n], ta = 0, td = 0, t, ba[n], bd[n];
  vector<pair<int, int> > aa, ad;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] < b[i]) {
      ta++;
      aa.push_back(make_pair(a[i], i));
      ba[i] = b[i];
      bd[i] = 2 * n + 1;
      ;
    } else {
      td++;
      ba[i] = 0;
      ad.push_back(make_pair(a[i], i));
      bd[i] = b[i];
    }
  }
  t = max(ta, td);
  int ans[t];
  if (ta > td) {
    ans[0] = max_element(ba, ba + n) - ba;
    sort(aa.begin(), aa.end(), comp);
    for (int i = 0; i < ta; i++) {
      if (aa[i].second != ans[0]) {
        ans[i] = aa[i].second;
      }
    }
  } else {
    ans[0] = min_element(bd, bd + n) - bd;
    sort(ad.begin(), ad.end(), compd1);
    for (int i = 0; i < td; i++) {
      if (ad[i].second != ans[0]) {
        ans[i] = ad[i].second;
      }
    }
  }
  printf("%d\n", t);
  for (int i = 0; i < t; i++) {
    printf("%d ", ans[i] + 1);
  }
}
