#include <bits/stdc++.h>
using namespace std;
void Out(vector<long long>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
}
void Input(vector<long long>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
struct elem {
  int first, second;
  int ind;
};
bool comp1(elem a, elem b) { return a.second > b.second; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<elem> a, b;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (x < y) {
      elem t;
      t.first = x;
      t.second = y;
      t.ind = i;
      a.push_back(t);
    } else {
      elem t;
      t.first = x;
      t.second = y;
      t.ind = i;
      b.push_back(t);
    }
  }
  if (a.size() > b.size()) {
    cout << a.size() << '\n';
    sort(a.begin(), a.end(), comp1);
    for (auto to : a) cout << to.ind << ' ';
  } else {
    cout << b.size() << '\n';
    sort(b.begin(), b.end(), comp1);
    reverse(b.begin(), b.end());
    for (auto to : b) cout << to.ind << ' ';
  }
}
