#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a, b;
map<pair<int, int>, int> m;
int n;
stack<pair<int, int> > st;
stack<pair<int, int> > s;
bool cmp(pair<int, int> u, pair<int, int> v) { return (u.first > v.first); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int u, v;
    cin >> u >> v;
    if (u < v)
      a.push_back({u, v});
    else
      b.push_back({u, v});
    m[{u, v}] = i;
  }
  sort(a.begin(), a.end(), cmp);
  sort(b.begin(), b.end());
  if (a.size() < b.size()) swap(a, b);
  cout << a.size() << '\n';
  for (auto it : a) cout << m[it] << ' ';
  return 0;
}
