#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long>> v;
  vector<pair<long long, long long>> z;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a < b) {
      v.push_back({b, i});
    } else {
      z.push_back({a, i});
    }
  }
  sort(v.begin(), v.end());
  sort(z.begin(), z.end());
  if (v.size() > z.size()) {
    cout << v.size() << "\n";
    for (long long i = v.size() * 1ll - 1ll; i > -1; i--) {
      cout << v[i].second + 1 * 1ll << " ";
    }
  } else {
    cout << z.size() << "\n";
    for (long long i = 0; i < z.size(); i++) {
      cout << z[i].second + 1 * 1ll << " ";
    }
  }
  return 0;
}
