#include <bits/stdc++.h>
using namespace std;
template <class T>
using VV = vector<vector<T>>;
template <class T>
inline T SMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
inline T SMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class Iter>
void __kumaerrc(Iter begin, Iter end) {
  for (; begin != end; ++begin) {
    cerr << *begin << ',';
  }
  cerr << endl;
}
void __kumaerr(istream_iterator<string> it) {
  (void)it;
  cerr << endl;
}
template <typename T, typename... Args>
void __kumaerr(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << ", ", __kumaerr(++it, args...);
}
template <typename S, typename T>
std::ostream& operator<<(std::ostream& _os, const std::pair<S, T>& _p) {
  return _os << "{" << _p.first << ',' << _p.second << "}";
}
const int MAX_N = 1e6 + 1;
int A[MAX_N][2];
int N;
void solve() {
  vector<tuple<int, int, int>> X, Y, Z;
  for (int i = 0; i < (N); ++i) {
    if (A[i][0] < A[i][1])
      X.emplace_back(-A[i][1], A[i][0], i);
    else
      Y.emplace_back(A[i][1], A[i][0], i);
  }
  if (int((X).size()) > int((Y).size()))
    Z = X;
  else
    Z = Y;
  sort((Z).begin(), (Z).end());
  fprintf(stdout, "%d", int((Z).size())), putchar('\n');
  ;
  for (int i = 0; i < (int((Z).size())); ++i) printf("%d ", get<2>(Z[i]) + 1);
  fprintf(stdout, ""), putchar('\n');
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(12) << fixed;
  cin >> N;
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (2); ++j) cin >> A[i][j];
  solve();
  return 0;
}
