#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
pair<int, int> a[MAXN];
pair<int, int> b[MAXN];
pair<int, int> c[MAXN];
int n, cnt1, cnt2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    if (a[i].first < a[i].second)
      b[++cnt1] = make_pair(a[i].second, i);
    else if (a[i].first > a[i].second)
      c[++cnt2] = make_pair(a[i].first, i);
  }
  if (cnt1 > cnt2) {
    sort(b + 1, b + cnt1 + 1);
    reverse(b + 1, b + cnt1 + 1);
    printf("%d\n", cnt1);
    for (int i = 1; i <= cnt1; i++) printf("%d ", b[i].second);
  } else {
    sort(c + 1, c + cnt2 + 1);
    printf("%d\n", cnt2);
    for (int i = 1; i <= cnt2; i++) printf("%d ", c[i].second);
  }
  return 0;
}
