#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5, mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int> > v1, v2;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x > y)
      v1.push_back({{y, x}, i});
    else
      v2.push_back({{y, x}, i});
  }
  cout << max(v1.size(), v2.size()) << '\n';
  if ((int)v1.size() > (int)v2.size()) {
    sort(v1.begin(), v1.end());
    for (auto i : v1) cout << i.second + 1 << " ";
  } else {
    sort(v2.rbegin(), v2.rend());
    for (auto i : v2) cout << i.second + 1 << " ";
  }
  return 0;
}
