#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  vector<pair<int, pair<int, int>>> b, second;
  for (i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x < y) {
      second.push_back(make_pair(i + 1, make_pair(x, y)));
    } else {
      b.push_back(make_pair(i + 1, make_pair(x, y)));
    }
  }
  if (second.size() > b.size()) {
    sort(second.begin(), second.end(),
         [&](pair<int, pair<int, int>> &k, pair<int, pair<int, int>> &l) {
           return k.second.second > l.second.second;
         });
    cout << second.size() << endl;
    for (i = 0; i < second.size(); i++) {
      cout << second[i].first << " ";
    }
  } else {
    sort(b.begin(), b.end(),
         [&](pair<int, pair<int, int>> &k, pair<int, pair<int, int>> &l) {
           return k.second.second < l.second.second;
         });
    cout << b.size() << endl;
    for (i = 0; i < b.size(); i++) {
      cout << b[i].first << " ";
    }
  }
}
