#include <bits/stdc++.h>
using namespace std;
int mod1 = 998244353;
int mod2 = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x = 0, y = 0, u, v;
  cin >> n;
  vector<int> a1, a2;
  vector<pair<int, int>> b1, b2;
  for (int i = 0; i < n; i++) {
    cin >> u >> v;
    if (u > v) {
      a1.push_back(u);
      b1.push_back(make_pair(v, i + 1));
    } else {
      a2.push_back(u);
      b2.push_back(make_pair(v, i + 1));
    }
  }
  u = a1.size();
  v = a2.size();
  if (u > v) {
    sort(b1.begin(), b1.end());
    cout << u << "\n";
    for (int i = 0; i < u; i++) cout << b1[i].second << " ";
  } else {
    sort(b2.begin(), b2.end());
    reverse(b2.begin(), b2.end());
    cout << v << "\n";
    for (int i = 0; i < v; i++) cout << b2[i].second << " ";
  }
  return 0;
}
