#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  char ch;
  bool ok;
  for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') ok = 1;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  if (ok) x = -x;
}
const int maxn = 3e5 + 10;
struct oo {
  int a, b, id;
} f[maxn], g[maxn];
int n, tot, sum;
bool cmp1(oo a, oo b) { return a.b > b.b; }
bool cmp2(oo a, oo b) { return a.a < b.a; }
int main() {
  read(n);
  for (register int i = 1, x, y; i <= n; i++) {
    read(x), read(y);
    if (y > x)
      f[++tot] = (oo){x, y, i};
    else
      g[++sum] = (oo){x, y, i};
  }
  if (tot > sum) {
    sort(f + 1, f + tot + 1, cmp1);
    printf("%d\n", tot);
    for (register int i = 1; i <= tot; i++)
      printf("%d%c", f[i].id, i == tot ? '\n' : ' ');
  } else {
    sort(g + 1, g + sum + 1, cmp2);
    printf("%d\n", sum);
    for (register int i = 1; i <= sum; i++)
      printf("%d%c", g[i].id, i == sum ? '\n' : ' ');
  }
}
