#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double pi = 3.1415926535897932384626;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 6e5 + 5;
int n, u, v, cnt1, cnt2;
struct node {
  int x, y, id;
} a[maxn], b[maxn];
bool cmp1(const node &a, const node &b) { return a.x > b.x; }
bool cmp2(const node &a, const node &b) { return a.y < b.y; }
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    u = read(), v = read();
    if (u < v)
      a[++cnt1] = {u, v, i};
    else if (u > v)
      b[++cnt2] = {u, v, i};
  }
  if (cnt1 > cnt2) {
    sort(a + 1, a + cnt1 + 1, cmp1);
    printf("%d\n", cnt1);
    for (int i = 1; i <= cnt1; ++i)
      printf("%d%c", a[i].id, i < cnt1 ? ' ' : '\n');
  } else {
    sort(b + 1, b + cnt2 + 1, cmp2);
    printf("%d\n", cnt2);
    for (int i = 1; i <= cnt2; ++i)
      printf("%d%c", b[i].id, i < cnt2 ? ' ' : '\n');
  }
  return 0;
}
