{$DEFINE DMI}
{$DEFINE DO0}
{$DEFINE DEBUG}
{$IFDEF DEBUG}
{$B-,I+,N+,O-,Q+,R+,S+}
{$ELSE}
{$B-,I-,N+,O+,Q-,R-,S-}
{$ENDIF}
{$APPTYPE CONSOLE}
Program OlympSol;
uses Math,SysUtils;

var p,t,i,j,n:integer;
a,b,num:array[1..2000] of integer;
d:array[0..2000,0..2000] of integer;

BEGIN
 assign (input, 'joke.in'); reset (input);
 assign (output, 'joke.out'); rewrite (output);
 read(n);
 for i:=1 to n do num[i]:=i;
 for i:=1 to n do read(a[i],b[i]);
 for i:=1 to n-1 do
 for j:=i+1 to n do
 if a[i]<a[j] then
 begin
 p:=a[i];
 a[i]:=a[j];
 a[j]:=p;
  p:=b[i];
 b[i]:=b[j];
 b[j]:=p;
   p:=num[i];
 num[i]:=num[j];
 num[j]:=p;
 end;
 d[0,0]:=0;
 if a[1]+b[1]>n-1 then d[0,1]:=0
 else begin
 d[0,1]:=1;
 d[1,1]:=1;
 end;

for i:=2 to n do
begin
        if a[i]+b[i]>n-1 then begin
        d[0,i]:=d[0,i-1];
        for j:=1 to d[0,i] do d[j,i]:=d[j,i-1];
        end
        else begin
        j:=i-1;
        d[0,i]:=1;
        d[1,i]:=i;
        while (j>0) and(a[j]<n-b[i])   do begin
        if (a[j]=a[i]) and (b[j]=b[i]) and (d[0,i]<n-a[i]-b[j]) then begin
         inc(d[0,i]);
         d[d[0,i],i]:=j;
         end;
         dec(j)
         end;
         d[0,i]:=d[0,i]+d[0,j];
         for t:=d[0,i]-d[0,j]+1 to d[0,i] do d[t,i]:=d[t-d[0,i]+d[0,j],j];
         if d[0,i]<d[0,i-1] then begin
        d[0,i]:=d[0,i-1];
        for j:=1 to d[0,i] do d[j,i]:=d[j,i-1];
         end;
        end;
end;
write(n-d[0,n],' ');
for i:=1 to n do begin
p:=0;
for j:=1 to d[0,n] do if d[j,n]=i then p:=1;
if p=0 then write(num[i],' ');
end;
END.
