#include <bits/stdc++.h>
using namespace std;
bool comp1(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
bool comp2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
map<pair<int, int>, int> mp;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > vp, ans1, ans2;
  vector<pair<int, int> > A, B;
  vp.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vp[i].first >> vp[i].second;
    if (vp[i].first < vp[i].second)
      A.push_back({vp[i].first, vp[i].second});
    else
      B.push_back(vp[i]);
    mp[vp[i]] = i + 1;
  }
  sort(A.begin(), A.end(), comp1);
  sort(B.begin(), B.end(), comp2);
  if (A.size() > B.size())
    ans1 = A;
  else
    ans1 = B;
  cout << ans1.size() << endl;
  for (auto val : ans1) {
    cout << mp[val] << " ";
  }
  return 0;
}
