#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long, long long>, long long> > le, gr;
bool cmp2(pair<pair<long long, long long>, long long> &a,
          pair<pair<long long, long long>, long long> &b) {
  if (a.first.second < b.first.second)
    return true;
  else
    return false;
}
bool cmp1(pair<pair<long long, long long>, long long> &a,
          pair<pair<long long, long long>, long long> &b) {
  if (a.first.second > b.first.second)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  for (int(i) = (0); (i) < (n); (i)++) {
    long long a, b;
    cin >> a >> b;
    if (a < b)
      le.push_back(make_pair(make_pair(a, b), i + 1));
    else
      gr.push_back(make_pair(make_pair(a, b), i + 1));
  }
  if (((int)le.size()) > ((int)gr.size())) {
    sort(le.begin(), le.end(), cmp1);
    cout << ((int)le.size()) << endl;
    for (int(i) = (0); (i) < (((int)le.size())); (i)++) {
      cout << le[i].second;
      if (i != ((int)le.size()) - 1)
        cout << " ";
      else
        cout << endl;
    }
  } else {
    sort(gr.begin(), gr.end(), cmp2);
    cout << ((int)gr.size()) << endl;
    for (int(i) = (0); (i) < (((int)gr.size())); (i)++) {
      cout << gr[i].second;
      if (i != ((int)gr.size()) - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
