#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> a, b;
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < y) {
      a.emplace_back(-y, i);
    } else {
      b.emplace_back(y, i);
    }
  }
  if ((int)b.size() > (int)a.size()) {
    a = b;
  }
  sort(a.begin(), a.end());
  printf("%d\n", (int)a.size());
  for (int i = 0; i < (int)a.size(); ++i) {
    if (i > 0) {
      putchar(' ');
    }
    printf("%d", a[i].second + 1);
  }
  putchar('\n');
}
