#include <bits/stdc++.h>
using namespace std;
int t, d, ct, q, ans, l, m, r, n, mx, mn, i, j, k, x, y, z, s;
char ch;
string ss = "", str = "";
int a[300005], b[300005];
bool comp(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(false), cin.tie(nullptr);
  cin >> n;
  vector<pair<pair<int, int>, int>> A, B;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    if (x > y)
      A.push_back({{x, y}, i});
    else
      B.push_back({{x, y}, i});
  }
  if (A.size() >= B.size()) {
    cout << A.size() << "\n";
    sort(A.begin(), A.end());
    for (i = 0; i < A.size(); i++) cout << A[i].second << " ";
    return 0;
  }
  cout << B.size() << "\n";
  sort(B.begin(), B.end(), comp);
  for (i = 0; i < B.size(); i++) cout << B[i].second << " ";
  return 0;
}
