#include <bits/stdc++.h>
using namespace std;
bool cmp1(pair<int, int>& a, pair<int, int>& b) { return b.second < a.second; }
bool cmp2(pair<int, int>& a, pair<int, int>& b) { return b.second > a.second; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
  vector<pair<int, int>> x, y;
  vector<int> r(2 * n + 1);
  for (int i = 0; i < n; ++i) {
    if (v[i].first < v[i].second)
      x.push_back(v[i]);
    else
      y.push_back(v[i]);
    r[v[i].first] = i + 1;
  }
  sort(x.begin(), x.end(), cmp1);
  sort(y.begin(), y.end(), cmp2);
  vector<int> id1, id2;
  int lst = 1e9;
  for (int i = 0; i < (int)x.size(); ++i) {
    if (x[i].first < lst) {
      id1.push_back(i);
      lst = x[i].second;
    }
  }
  lst = 0;
  for (int i = 0; i < (int)y.size(); ++i) {
    if (y[i].first > lst) {
      id2.push_back(i);
      lst = y[i].second;
    }
  }
  if (id1.size() > id2.size()) {
    cout << id1.size() << '\n';
    for (auto p : id1) {
      cout << r[x[p].first] << ' ';
    }
    cout << '\n';
  } else {
    cout << id2.size() << '\n';
    for (auto p : id2) cout << r[y[p].first] << ' ';
    cout << '\n';
  }
}
