#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
int n, a, b, ind[600001];
vector<pair<int, int> > v1, v2;
bool cmp1(pair<int, int> p1, pair<int, int> p2) { return p1.first > p2.first; }
bool cmp2(pair<int, int> p1, pair<int, int> p2) {
  return p1.second < p2.second;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    ind[a] = i + 1;
    if (a > b) {
      v2.push_back({a, b});
    } else {
      v1.push_back({a, b});
    }
  }
  sort(v1.begin(), v1.end(), cmp1);
  sort(v2.begin(), v2.end(), cmp2);
  if (v1.size() >= v2.size()) {
    cout << v1.size() << "\n";
    for (auto z : v1) {
      cout << ind[z.first] << " ";
    }
  } else {
    cout << v2.size() << "\n";
    for (auto z : v2) {
      cout << ind[z.first] << " ";
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int test_cases = 1;
  for (int i = 0; i < test_cases; i++) {
    solve();
  }
  return 0;
}
