#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 5;
const int INF = 1e9 + 7;
struct note {
  int a, pos;
} a[maxn], b[maxn];
bool cmp1(note t1, note t2) { return t1.a < t2.a; }
bool cmp2(note t1, note t2) { return t1.a > t2.a; }
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  int l1 = 0, l2 = 0;
  for (int q = 1; q <= n; q++) {
    scanf("%d%d", &x, &y);
    if (x > y) {
      a[l1++] = note{x, q};
    } else {
      b[l2++] = note{x, q};
    }
  }
  if (l1 > l2) {
    sort(a, a + l1, cmp1);
    printf("%d\n", l1);
    for (int q = 0; q < l1; q++) printf("%d ", a[q].pos);
  } else {
    sort(b, b + l2, cmp2);
    printf("%d\n", l2);
    for (int q = 0; q < l2; q++) printf("%d ", b[q].pos);
  }
  puts("");
  return 0;
}
