#include <bits/stdc++.h>
using namespace std;
struct t {
  long long int first;
  long long int second;
  long long int index;
};
bool compare1(t a, t b) { return a.second > b.second; }
bool compare2(t a, t b) { return a.first < b.first; }
int32_t main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (long long int i = 0; i < n; i++) cin >> a[i] >> b[i];
  vector<t> v1, v2;
  for (long long int i = 0; i < n; i++) {
    if (a[i] < b[i]) {
      t test;
      test.first = a[i];
      test.second = b[i];
      test.index = i + 1;
      v1.push_back(test);
    } else if (a[i] > b[i]) {
      t test;
      test.first = a[i];
      test.second = b[i];
      test.index = i + 1;
      v2.push_back(test);
    }
  }
  cout << max(v1.size(), v2.size()) << "\n";
  if (v1.size() > v2.size()) {
    sort(v1.begin(), v1.end(), compare1);
    for (long long int i = 0; i < v1.size(); i++) cout << v1[i].index << " ";
    cout << "\n";
  } else {
    sort(v2.begin(), v2.end(), compare2);
    for (long long int i = 0; i < v2.size(); i++) cout << v2[i].index << " ";
    cout << "\n";
  }
  return 0;
}
