#include <bits/stdc++.h>
using namespace std;
struct N {
  int x, y, id;
};
bool cmp1(N a, N b) { return a.x < b.x; }
bool cmp2(N a, N b) { return a.x > b.x; }
vector<N> A, B;
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < y)
      A.push_back({x, y, i});
    else
      B.push_back({x, y, i});
  }
  if (A.size() > B.size()) {
    sort(A.begin(), A.end(), cmp2);
    printf("%d\n", A.size());
    for (auto x : A) printf("%d ", x.id);
  } else {
    sort(B.begin(), B.end(), cmp1);
    printf("%d\n", B.size());
    for (auto x : B) printf("%d ", x.id);
  }
}
