{$APPTYPE CONSOLE}
{$Q+,R+}

uses SysUtils;
var fi,f,need:array[0..1000] of integer;
    ch1,ch2,c1,c2:array[1..1000] of integer;
    g,h:array[0..1000,0..1000] of integer;
    needb,ans:array[0..1000] of boolean;
    i,j,c,n,x,y,a,b:integer;
function min(a,b:integer):integer;
begin
  if a<b then
   min:=a
  else
   min:=b;
end;
begin
  reset(input,'joke.in');
  rewrite(output,'joke.out');
  fillchar(fi,sizeof(fi),0);
  fillchar(f,sizeof(f),0);
  fillchar(need,sizeof(need),0);
  fillchar(ch1,sizeof(ch1),0);
  fillchar(ch2,sizeof(ch2),0);
  fillchar(c1,sizeof(c1),0);
  fillchar(c2,sizeof(c2),0);
  fillchar(g,sizeof(g),0);
  fillchar(h,sizeof(h),0);
  fillchar(needb,sizeof(needb),0);
  fillchar(ans,sizeof(ans),0);
  read(c);
  n:=0;
  for i:=1 to c do
   begin
     read(x,y);
     if x+y<=c-1 then
      begin
        inc(h[x,c-x-y]);
        inc(n);
        ch1[n]:=x;
        ch2[n]:=c-x-y;
        c1[i]:=x;
        c2[i]:=c-x-y;
      end
     else
      begin
        c1[i]:=-1;
        c2[i]:=-1;
      end;
   end;
  for i:=1 to c do
   begin
     for j:=1 to i do
      g[i,j]:=f[i-j]+min(j,h[i-j,j]);
     f[i]:=f[i-1];//g[i,1];
     fi[i]:=0;
     for j:=1 to i do
      if g[i,j]>f[i] then
       begin
         f[i]:=g[i,j];
         fi[i]:=j;
       end;
   end;
  write(n-f[n]);
  b:=c;
  repeat
   a:=b-fi[b];
   need[a]:=fi[b];
   needb[a]:=true;
   b:=a;
    while(fi[b]=0) and (b>0) do
     dec(b);
  until b=0;
  for i:=1 to c do
   if (c1[i]<>-1) and (needb[c1[i]] and (c2[i]=need[c1[i]])) then
    ans[i]:=true;
  for i:=1 to c do
   if not ans[i] then
    write(' ',i);
end.
