#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
long long n;
vector<pair<pair<long long, long long>, long long>> inc;
vector<pair<pair<long long, long long>, long long>> ddec;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b)
      ddec.push_back({{b, a}, i + 1});
    else
      inc.push_back({{-a, b}, i + 1});
  }
  sort(inc.begin(), inc.end());
  sort(ddec.begin(), ddec.end());
  if (inc.size() > ddec.size()) {
    cout << inc.size() << endl;
    for (long long i = 0; i < inc.size(); i++) {
      cout << inc[i].second << " ";
    }
  } else {
    cout << ddec.size() << endl;
    for (long long i = 0; i < ddec.size(); i++) cout << ddec[i].second << " ";
  }
}
