#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int a[N], b[N];
void Print(const vector<int> &v) {
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%d%c", v[i], " \n"[i == v.size() - 1]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> up, down;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] > b[i])
      down.push_back(i);
    else
      up.push_back(i);
  }
  sort(up.begin(), up.end(), [&](int x, int y) { return b[x] > b[y]; });
  sort(down.begin(), down.end(), [&](int x, int y) { return b[x] < b[y]; });
  if (up.size() > down.size())
    Print(up);
  else
    Print(down);
}
