#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 14;
int n, a[maxn], b[maxn];
vector<int> ai, bi;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] < b[i])
      ai.push_back(i);
    else {
      bi.push_back(i);
      swap(a[i], b[i]);
    }
  }
  vector<int> ans;
  bool rev = 0;
  for (auto v : {ai, bi}) {
    sort(v.begin(), v.end(), [](int i, int j) { return b[i] > b[j]; });
    int cur = INT_MAX;
    vector<int> me;
    for (auto i : v)
      if (a[i] < cur) {
        me.push_back(i);
        cur = b[i];
      }
    if (rev) reverse(me.begin(), me.end());
    if (me.size() > ans.size()) ans = me;
    rev ^= 1;
  }
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i + 1 << ' ';
  cout << '\n';
}
