#include <stdio.h>
#define MAX 1024

int n;
int A[MAX],B[MAX];
bool lie[MAX][MAX];
int a[MAX][MAX];
int b[MAX][MAX];
int p[MAX][MAX];

void Rec(int x, int y) {
	if (p[x][y]==0) {
		lie[x][y] = false;
	}
	else {
		Rec(x+n-y-p[x][y],y);
		Rec(x,y+p[x][y]);
	}
}

int main() {
	int i,j,k,pred,best,x,y,cur;
	freopen("joke.in", "rt", stdin);
	freopen("joke.out", "wt", stdout);
	scanf("%d", &n);
	for (i=0; i<n; i++)
		for (j=0; j<n; j++)
			b[i][j] = 0;
	for (i=0; i<n; i++) {
		scanf("%d%d", &x, &y);
		A[i] = x;
		B[i] = y;
		if (x+y<n)
			b[x][y]++;
	}
	for (i=n-1; i>=0; i--)
		for (j=0; j<=i; j++) {
			best = b[i-j][j];
			pred = 0;
			for (k=1; k+i<n; k++) {
				cur = a[i-j][j+k] + a[n-j-k][j];
				if (cur > best) {
					best = cur;
					pred = k;
					if (best==i+1) break;
				}
			}
			a[i-j][j] = best;
			p[i-j][j] = pred;
		}
	printf("%d", n-a[0][0]);
	for (i=0; i<n; i++)
		for (j=0; j<n; j++)
			lie[i][j] = true;
	Rec(0,0);
	for (i=0; i<n; i++)
		if (A[i]+B[i]>=n || lie[A[i]][B[i]])
			printf(" %d", i+1);
	printf("\n");
	return 0;
}