#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int n;
pair<pair<int, int>, int> arr[N], a[N], b[N];
bool cmpa(const pair<pair<int, int>, int>& first,
          const pair<pair<int, int>, int>& second) {
  return first.first.first > second.first.first;
}
bool cmpb(const pair<pair<int, int>, int>& first,
          const pair<pair<int, int>, int>& second) {
  return first.first.second < second.first.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  int as = 0, bs = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].first.first >> arr[i].first.second;
    arr[i].second = i;
    if (arr[i].first.first < arr[i].first.second)
      a[as++] = arr[i];
    else
      b[bs++] = arr[i];
  }
  if (as > bs) {
    cout << as << '\n';
    sort(a, a + as, cmpa);
    for (int i = 0; i < as; ++i) cout << a[i].second + 1 << ' ';
  } else {
    cout << bs << '\n';
    sort(b, b + bs, cmpb);
    for (int i = 0; i < bs; ++i) cout << b[i].second + 1 << ' ';
  }
}
