#include <bits/stdc++.h>
using namespace std;
const long long maxx = 2e6 + 1314;
long long read() {
  long long k;
  scanf("%lld", &k);
  return k;
}
long long p[maxx], n;
long long x[maxx], y[maxx], top;
void init(long long X, long long Y) {
  x[++top] = X;
  y[top] = Y;
}
long long idx[maxx];
struct edge {
  long long x, y, id;
} A[maxx], w[maxx];
bool my(edge a, edge b) { return a.y > b.y; }
bool mt(edge a, edge b) { return a.y < b.y; }
long long ans1;
vector<edge> Aa[3];
long long ans[3];
void slove(long long f) {
  if (f == 1)
    sort(w + 1, w + 1 + top, my);
  else
    sort(w + 1, w + 1 + top, mt);
  ans[f]++;
  long long Max = w[1].y;
  Aa[f].push_back(w[1]);
  if (f == 1)
    for (long long i = 2; i <= top; i++)
      if (Max > w[i].x) ans[f]++, Max = w[i].y, Aa[1].push_back(w[i]);
  if (f == 2)
    for (long long i = 2; i <= top; i++)
      if (Max < w[i].x) ans[f]++, Max = w[i].y, Aa[2].push_back(w[i]);
  return;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++)
    A[i].x = read(), A[i].y = read(), A[i].id = i;
  for (long long i = 1; i <= n; i++)
    if (A[i].x < A[i].y) w[++top] = A[i];
  slove(1);
  top = 0;
  for (long long i = 1; i <= n; i++)
    if (A[i].x > A[i].y) w[++top] = A[i];
  slove(2);
  if (ans[2] > ans[1]) swap(ans[1], ans[2]), swap(Aa[1], Aa[2]);
  long long len = Aa[1].size();
  cout << ans[1] << endl;
  for (long long i = 0; i < len; i++) cout << Aa[1][i].id << ' ';
  cout << endl;
  return 0;
}
