#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmin(T& a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, T b) {
  return a < b ? a = b, 1 : 0;
}
void _run(string& out) {
  int n;
  cin >> n;
  vector<pair<int, int>> increasing, decreasing;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a < b) {
      increasing.push_back(make_pair(a, i + 1));
    } else {
      decreasing.push_back(make_pair(a, i + 1));
    }
  }
  if (increasing.size() > decreasing.size()) {
    out += to_string(increasing.size()) + "\n";
    sort(increasing.begin(), increasing.end());
    reverse(increasing.begin(), increasing.end());
    for (pair<int, int> pp : increasing) {
      out += to_string(pp.second) + " ";
    }
  } else {
    out += to_string(decreasing.size()) + "\n";
    sort(decreasing.begin(), decreasing.end());
    for (pair<int, int> pp : decreasing) {
      out += to_string(pp.second) + " ";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  {
    string out;
    _run(out);
    cout << out << "\n";
  }
  return 0;
}
