#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> s[300009];
pair<int, int> s1[300009], s2[300009];
bool cmp1(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
bool cmp2(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
void solve() {
  int tp1 = 0, tp2 = 0;
  for (int i = 1; i <= n; i++)
    if (s[i].first < s[i].second)
      s1[++tp1] = pair<int, int>(s[i].first, i);
    else
      s2[++tp2] = pair<int, int>(s[i].first, i);
  if (tp1 > tp2) {
    sort(s1 + 1, s1 + tp1 + 1, cmp1);
    printf("%d\n", tp1);
    for (int i = 1; i <= tp1; i++) printf("%d ", s1[i].second);
  } else {
    sort(s2 + 1, s2 + tp2 + 1, cmp2);
    printf("%d\n", tp2);
    for (int i = 1; i <= tp2; i++) printf("%d ", s2[i].second);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &s[i].first, &s[i].second);
  solve();
  return 0;
}
