{$O-,R+,Q+}
const
  inf = 10000;

var
 bj, t, res, nl, sp, i,j, n:longint;
 sh, a,b, ind:array[1..1001] of longint;
 lie:array[1..1000] of boolean;
 w, w1, f: array[0..1000] of array[-1000..1000] of integer;
 rs: array[1..1000] of integer;
 rss: integer;


begin
 assign(input,'joke.in'); reset(input);
 assign(output,'joke.out'); rewrite(output);
 read(n);
 for i:=1 to n do begin
  read(a[i],b[i]);
  ind[i] := i;
  if a[i]+b[i]>=n then
   lie[i]:=true;
 end;

 for i := 1 to n do for j := i + 1 to n do
   if (a[i] > a[j]) or ((a[i] = a[j]) and ( b[i] > b[j])) then begin
     t := ind[i];
     ind[i] := ind[j];
     ind[j] := t;
     t := a[i];
     a[i] := a[j];
     a[j] := t;
     t := b[i];
     b[i] := b[j];
     b[j] := t;
   end;

 for i := 1 to n do begin
   sh[i] := 0;
   j := i - 1;
   while ( j > 0 ) and ( a[j] = a[i] ) and ( b[j] = b[i] ) do begin
     inc( sh[i] );
     dec( j );
   end;
 end;
 
 for j := -1000 to 1000 do
   f[0][j] := 0;
   
 for i := 1 to n do begin
   for j := -1000 to 1000 do
     if f[i - 1][j] > 0 then begin
       f[i][j-1] := f[i - 1][j];
       w[i][j-1] := inf;
     end;

   if a[i] + b[i] >= n then
     continue;
   if sh[i] = sh[i+1] - 1 then continue;
   
   for j := -i to i do begin
     sp := i + j - 1 - sh[i];
     if ( a[i] < sp ) then
       continue;
     nl := a[i] - sp;
     nl := nl + n - a[i] - b[i] - 1- sh[i];
     if f[i][j+nl] <= f[i-1-sh[i]][j] + sh[i] + 1 then begin
       w[i][j+nl] := j;
       f[i][j+nl] := f[i-1-sh[i]][j] + sh[i] + 1;
     end;
   end;
 end;

 res := 0;
 bj := 0;
 for j := -1000 to 0 do if f[n][j] > res then begin
 res := f[n][j];
 bj := j;
 end;

 j := bj;
 rss := 0;
 i := n;
 while i >= 1  do begin
   if ( w[i][j] = inf ) or ( f[i][j] = 0 ) then begin
     inc( j );
     inc( rss );
     rs[rss] := ind[i];
     dec( i );
   end else begin
     j := w[i][j];
     dec( i, sh[i] );
     dec( i );
   end;
 end;

 write( rss, ' ' );
 for i := 1 to rss do
   write( rs[i], ' ' );


end.

