#include <bits/stdc++.h>
using namespace std;
int binarys(vector<long long> a, int l, int r, int x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (a[m] == x) return m;
    if (a[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
vector<int> a(300001), b(300001);
vector<int> v1, v2;
bool comp2(int x, int y) { return a[x] < a[y]; }
bool comp1(int x, int y) { return b[x] > b[y]; }
int main() {
  long long n, m = 0, i, flag = 1, ans = 0, x = 0, l = 0, r = 0, ta, tb, j = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] < b[i]) {
      v1.push_back(i);
    } else {
      v2.push_back(i);
    }
  }
  if (v1.size() > v2.size()) {
    cout << v1.size() << endl;
    sort(v1.begin(), v1.end(), comp1);
    for (i = 0; i < v1.size(); i++) cout << v1[i] << " ";
    cout << endl;
  } else {
    cout << v2.size() << endl;
    sort(v2.begin(), v2.end(), comp2);
    for (int i = 0; i < v2.size(); ++i) cout << v2[i] << " ";
  }
}
