#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, a[N], b[N];
vector<int> up, down;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] < b[i]) {
      up.push_back(i);
    } else {
      down.push_back(i);
    }
  }
  cout << max(up.size(), down.size()) << endl;
  vector<int> v = up.size() > down.size() ? up : down;
  sort(v.begin(), v.end(), [&](int x, int y) -> bool {
    if (a[x] < b[x]) {
      return b[x] > b[y];
    } else {
      return a[x] < a[y];
    }
  });
  for (int x : v) cout << x << " ";
  cout << endl;
  return 0;
}
