#include <bits/stdc++.h>
using namespace std;
int n;
struct hdm {
  int first, second, id;
  hdm(){};
  hdm(int first, int second, int id) : first(first), second(second), id(id){};
};
vector<hdm> v1, v2;
bool cmp1(hdm A, hdm B) { return (A.second < B.second); }
bool cmp2(hdm A, hdm B) { return (A.first > B.first); }
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int A, B;
    cin >> A >> B;
    pair<int, int> p = make_pair(A, B);
    if (A > B) {
      v1.push_back(hdm(A, B, i));
    } else {
      v2.push_back(hdm(A, B, i));
    }
  }
  sort(v1.begin(), v1.end(), cmp1);
  sort(v2.begin(), v2.end(), cmp2);
  int rs1 = (int)v1.size();
  int rs2 = (int)v2.size();
  if (rs1 >= rs2) {
    cout << rs1 << '\n';
    for (int i = 0; i < v1.size(); i++) cout << v1[i].id << ' ';
  } else {
    cout << rs2 << '\n';
    for (int i = 0; i < v2.size(); i++) cout << v2[i].id << ' ';
  }
  return 0;
}
