#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Data {
  int a, b, indx;
  Data(int aa, int bb, int cc) {
    a = aa;
    b = bb;
    indx = cc;
  }
  Data() { a = b = indx = 0; }
};
bool cmp1(Data x, Data y) { return (x.a < y.a); }
bool cmp2(Data x, Data y) { return (x.a > y.a); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  std::vector<Data> ab, ba;
  for (int i = 1; i <= n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a > b)
      ab.push_back(Data(a, b, i));
    else
      ba.push_back(Data(a, b, i));
  }
  sort(ab.begin(), ab.end(), cmp1);
  sort(ba.begin(), ba.end(), cmp2);
  if (ab.size() > ba.size()) {
    cout << ab.size() << '\n';
    for (int i = 0; i < ab.size(); ++i) cout << ab[i].indx << " ";
  } else {
    cout << ba.size() << '\n';
    for (int i = 0; i < ba.size(); ++i) cout << ba[i].indx << " ";
  }
  return 0;
}
