#include <bits/stdc++.h>
using namespace std;
bool cmp1(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
bool cmp2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, x, y;
  cin >> n;
  vector<pair<int, int>> v1, v2;
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x < y)
      v1.push_back({x, y});
    else
      v2.push_back({x, y});
    mp[{x, y}] = i + 1;
  }
  sort(v1.begin(), v1.end(), cmp1);
  sort(v2.begin(), v2.end(), cmp2);
  if (v1.size() >= v2.size()) {
    cout << v1.size() << endl;
    for (auto i : v1) {
      cout << mp[i] << " ";
    }
    cout << endl;
  } else {
    cout << v2.size() << endl;
    for (auto i : v2) {
      cout << mp[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
