#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > u, d;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    if (t1 > t2) {
      d.push_back({t2, i + 1});
    }
    if (t2 > t1) {
      u.push_back({-t1, i + 1});
    }
  }
  if (d.size() > u.size()) {
    printf("%d\n", d.size());
    sort(d.begin(), d.end());
    for (auto i : d) printf("%d ", i.second);
  } else {
    printf("%d\n", u.size());
    sort(u.begin(), u.end());
    for (auto i : u) printf("%d ", i.second);
  }
}
