#include <bits/stdc++.h>
using namespace std;
struct Segment {
  int x, y;
  int idx;
};
vector<Segment> ls, rs;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    Segment s;
    scanf("%d %d", &s.x, &s.y);
    s.idx = i;
    if (s.x < s.y) {
      ls.push_back(s);
    } else {
      rs.push_back(s);
    }
  }
  vector<Segment> lpos, rpos;
  sort(ls.begin(), ls.end(),
       [](const Segment& a, const Segment& b) { return a.y > b.y; });
  Segment prev;
  for (auto s : ls) {
    if (lpos.empty() || s.x < prev.y) {
      lpos.push_back(s);
      prev = s;
    }
  }
  sort(rs.begin(), rs.end(),
       [](const Segment& a, const Segment& b) { return a.y < b.y; });
  for (auto s : rs) {
    if (rpos.empty() || s.x > prev.y) {
      rpos.push_back(s);
      prev = s;
    }
  }
  if (lpos.size() > rpos.size()) {
    printf("%d\n", (int)lpos.size());
    for (auto s : lpos) {
      printf("%d ", s.idx);
    }
  } else {
    printf("%d\n", (int)rpos.size());
    for (auto s : rpos) {
      printf("%d ", s.idx);
    }
  }
  printf("\n");
  return 0;
}
