#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 3e6 + 100;
const int maxm = 2e6 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
struct Node {
  int x, y;
  int id;
} node[maxn];
vector<Node> a, b;
bool cmp(Node a, Node b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    node[i].id = i;
    scanf("%d %d", &node[i].x, &node[i].y);
    if (node[i].x < node[i].y)
      a.push_back(node[i]);
    else
      b.push_back(node[i]);
  }
  printf("%d\n", max(a.size(), b.size()));
  sort(a.begin(), a.end(), cmp);
  sort(b.begin(), b.end(), cmp);
  if (a.size() > b.size()) {
    for (int i = a.size() - 1; i >= 0; i--) {
      printf("%d ", a[i].id);
    }
  } else {
    for (int i = 0; i < b.size(); i++) printf("%d ", b[i].id);
  }
  return 0;
}
