#include <bits/stdc++.h>
using namespace std;
struct node {
  int a;
  int b;
  int index;
};
bool compare(node &n1, node &n2) {
  if (n1.a < n2.a)
    return true;
  else
    return false;
}
bool compare1(node &n1, node &n2) {
  if (n1.b < n2.b)
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  vector<node> pq(n);
  for (int i = 0; i < n; i++) {
    cin >> pq[i].a >> pq[i].b;
    pq[i].index = i;
  }
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (pq[i].a < pq[i].b) num++;
  }
  vector<node> track;
  if (num >= n / 2) {
    for (int i = 0; i < n; i++) {
      if (pq[i].a < pq[i].b) track.push_back(pq[i]);
    }
    sort(track.begin(), track.end(), compare);
    cout << track.size() << endl;
    for (int i = track.size() - 1; i >= 0; i--) {
      cout << track[i].index + 1 << " ";
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (pq[i].a > pq[i].b) track.push_back(pq[i]);
    }
    sort(track.begin(), track.end(), compare1);
    cout << track.size() << endl;
    for (int i = 0; i < track.size(); i++) {
      cout << track[i].index + 1 << " ";
    }
  }
  return 0;
}
