#include <bits/stdc++.h>
using namespace std;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2> &p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
bool sort1(const pair<pair<int, int>, int> &a,
           const pair<pair<int, int>, int> &b) {
  return (a.first.second < b.first.second);
}
bool sort2(const pair<pair<int, int>, int> &a,
           const pair<pair<int, int>, int> &b) {
  return (a.first.first > b.first.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> a, b;
    for (int i = 0; i < n; i++) {
      long long c, d;
      cin >> c >> d;
      if (c > d)
        a.push_back(make_pair(make_pair(c, d), i + 1));
      else
        b.push_back(make_pair(make_pair(c, d), i + 1));
    }
    sort(a.begin(), a.end(), sort1);
    sort(b.begin(), b.end(), sort2);
    if (a.size() > b.size()) {
      cout << a.size() << "\n";
      for (auto z : a) cout << z.second << " ";
    } else {
      cout << b.size() << "\n";
      for (auto z : b) cout << z.second << " ";
    }
  }
}
