#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, sum1, sum2;
pair<pair<int, int>, int> a[N], b[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < y)
      a[++sum1] = make_pair(make_pair(y, x), i);
    else if (x > y)
      b[++sum2] = make_pair(make_pair(y, x), i);
  }
  if (sum1 >= sum2) {
    sort(a + 1, a + sum1 + 1, greater<pair<pair<int, int>, int> >());
    printf("%d\n", sum1);
    for (int i = 1; i <= sum1; i++) printf("%d ", a[i].second);
  } else {
    sort(b + 1, b + sum2 + 1);
    printf("%d\n", sum2);
    for (int i = 1; i <= sum2; i++) printf("%d ", b[i].second);
  }
  return 0;
}
