#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 62);
const int inf = (1 << 30);
const long long nmax = 3e5 + 50;
const int mod = 1e9 + 7;
using namespace std;
int n, i, x, y;
vector<pair<pair<int, int>, int> > a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    if (x > y)
      a.push_back({{y, x}, i});
    else
      b.push_back({{x, y}, i});
  }
  if (a.size() >= b.size()) {
    cout << a.size() << endl;
    sort(a.begin(), a.end());
    for (i = 0; i < a.size(); i++) cout << a[i].second << " ";
  } else {
    cout << b.size() << endl;
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    for (i = 0; i < b.size(); i++) cout << b[i].second << " ";
  }
  cout << endl;
  return 0;
}
