#include <bits/stdc++.h>
using namespace std;
int powmod(int a, int b, int mod) {
  int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int set(int b, int i) { return b | (1 << i); }
int unset(int b, int i) { return b & !(1 << i); }
int check(int b, int i) { return b & (1 << i); }
const long long inf = 0xFFFFFFFFFFFFFFFL;
int32_t main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<pair<pair<long long, long long>, long long> > a;
  vector<pair<pair<long long, long long>, long long> > b;
  for (long long i = 0; i < n; i++) {
    long long v1, v2;
    cin >> v1 >> v2;
    if (v1 < v2) {
      a.push_back({{v2, v1}, i});
    } else {
      b.push_back({{v1, v2}, i});
    }
  }
  if (a.size() > b.size()) {
    sort((a).begin(), (a).end());
    cout << a.size() << "\n";
    for (long long i = a.size() - 1; i >= 0; i--)
      cout << a[i].second + 1 << " ";
    cout << "\n";
  } else {
    sort((b).begin(), (b).end());
    cout << b.size() << "\n";
    for (long long i = 0; i < b.size(); i++) cout << b[i].second + 1 << " ";
    cout << "\n";
  }
  return 0;
}
