#include <bits/stdc++.h>
using namespace std;
int a[600002];
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> pairs;
  vector<int> smaller, bigger;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    pairs.push_back({x, y});
    a[y] = i + 1;
    if (x < y)
      bigger.push_back(y);
    else
      smaller.push_back(y);
  }
  if (bigger.size() > smaller.size()) {
    sort(bigger.rbegin(), bigger.rend());
    cout << bigger.size() << "\n";
    for (long long i = 0; i < bigger.size(); i++) cout << a[bigger[i]] << " ";
  } else {
    sort(smaller.begin(), smaller.end());
    cout << smaller.size() << "\n";
    for (long long i = 0; i < smaller.size(); i++) cout << a[smaller[i]] << " ";
  }
}
