#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n;
typedef struct node {
  int a, b;
  int type;
  int idx;
} NODE;
NODE p[maxn];
int type;
bool cmp1(const NODE x, const NODE y) { return x.type < y.type; }
bool cmp2(const NODE x, const NODE y) { return x.b > y.b; }
bool cmp3(const NODE x, const NODE y) { return x.b < y.b; }
int main() {
  int n;
  cin >> n;
  type = 0;
  int ta, tb;
  ta = tb = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &p[i].a, &p[i].b);
    p[i].idx = i;
    if (p[i].a < p[i].b) {
      p[i].type = 1;
      ta++;
    } else {
      p[i].type = 2;
      tb++;
    }
  }
  sort(p + 1, p + 1 + n, cmp1);
  if (ta > tb) {
    type = 1;
    sort(p + 1, p + 1 + ta, cmp2);
    printf("%d\n", ta);
    for (int i = 1; i <= ta; i++) {
      printf("%d ", p[i].idx);
    }
    printf("\n");
  } else {
    type = 2;
    sort(p + 1 + ta, p + 1 + ta + tb, cmp3);
    printf("%d\n", tb);
    for (int i = ta + 1; i <= ta + tb; i++) {
      printf("%d ", p[i].idx);
    }
    printf("\n");
  }
}
