{$APPTYPE CONSOLE}
var k,p,f,b,a:array[0..1100] of longint;
    i,j,max,maxk,maxp,n,m,c:longint;
    t:array [1..1100,1..1100] of integer;
    bool:array [1..1100] of boolean;

{function cmp(i,j:longint):longint;
var ni,nj:longint;
begin
    ni:=a[i]+b[i]*1100;nj:=a[j]+b[j]*1100;
    if ni<nj then cmp:=-1
    else if ni>nj then cmp:=1
    else cmp:=0;
end;  }

function min(x,y:longint):longint;
begin
    if x<y then min:=x else min:=y;
end;

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]);
        if a[i]+1<=n-b[i] then inc(t[a[i]+1,n-b[i]]);
    end;
    //qsort(1,n);

    for i:=1 to n do begin
        f[i]:=f[i-1]; p[i]:=i;
        for j:=i downto 1 do begin
            if f[i]<f[j-1]+min(t[j,i],i-j+1) then begin
                f[i]:=f[j-1]+min(t[j,i],i-j+1);
                p[i]:=j;
            end;
        end;
    end;

    write(n-f[n],' ');
    m:=n;
    while m>0 do  begin
        c:=0;
        for i:=1 to n do
            if (a[i]+1=p[m]) and (n-b[i]=m) and (c<n-a[i]-b[i]) then begin
                bool[i]:=true;;
                inc(c);
            end;
        m:=p[m]-1;
    end;
    for i:=1 to n do if not bool[i] then write(i,' ');
end.
