#include <bits/stdc++.h>
using namespace std;
void solve(istream& in, ostream& out) {
  int n;
  in >> n;
  vector<tuple<int, int, int>> p;
  for (int i = 0; i < n; ++i) {
    int a, b;
    in >> a >> b;
    p.emplace_back(b, a, i);
  }
  sort(p.begin(), p.end());
  vector<int> res1;
  for (int i = n - 1; i >= 0; --i) {
    if (get<0>(p[i]) > get<1>(p[i])) {
      res1.emplace_back(get<2>(p[i]));
    }
  }
  for (int i = 0; i < n; ++i) {
    swap(get<0>(p[i]), get<1>(p[i]));
  }
  sort(p.begin(), p.end());
  vector<int> res2;
  for (int i = n - 1; i >= 0; --i) {
    if (get<0>(p[i]) > get<1>(p[i])) {
      res2.emplace_back(get<2>(p[i]));
    }
  }
  reverse(res2.begin(), res2.end());
  vector<int> res = res1.size() > res2.size() ? res1 : res2;
  out << res.size() << endl;
  for (int x : res) out << x + 1 << " ";
  out << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solve(in, out);
}
