#include <bits/stdc++.h>
using namespace std;
bool first_bool(const pair<pair<int, int>, int>& a,
                const pair<pair<int, int>, int>& b) {
  return a.first.first > b.first.first;
}
bool second_bool(const pair<pair<int, int>, int>& a,
                 pair<pair<int, int>, int>& b) {
  return a.first.second < b.first.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > arr(n);
  vector<pair<pair<int, int>, int> > first_, second_;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].first >> arr[i].second;
    if (arr[i].first < arr[i].second) {
      first_.push_back({arr[i], i});
    }
    if (arr[i].first > arr[i].second) {
      second_.push_back({arr[i], i});
    }
  }
  int ans1 = first_.size(), ans2 = second_.size();
  sort(first_.begin(), first_.end(), first_bool);
  sort(second_.begin(), second_.end(), second_bool);
  if (ans1 < ans2) {
    cout << ans2 << endl;
    for (int i = 0; i < ans2; ++i) {
      cout << second_[i].second + 1 << " ";
    }
  } else {
    cout << ans1 << endl;
    for (int i = 0; i < ans1; ++i) {
      cout << first_[i].second + 1 << " ";
    }
  }
  return 0;
}
