#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3e5 + 10;
pair<pair<int, int>, int> a[N], b[N];
int ib, ia;
bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second > b.first.second;
}
bool comp1(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second < b.first.second;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (x < y) {
      a[ia].first.first = x;
      a[ia].first.second = y;
      a[ia].second = i;
      ia++;
    } else {
      b[ib].first.first = x;
      b[ib].first.second = y;
      b[ib].second = i;
      ib++;
    }
  }
  sort(a, a + ia, comp);
  sort(b, b + ib, comp1);
  pair<pair<int, int>, int>* x = (ib > ia ? b : a);
  n = (ib > ia ? ib : ia);
  cout << n << endl;
  for (long long i = 0; i < n; i++) cout << x[i].second << " ";
  return 0;
}
