{$APPTYPE CONSOLE}
program zzz;

var
  ans: array[1..1000] of Boolean;
  aa,bb,i,dx,j,k,n,m: longint;
  link,best,a,b: array[0..1000] of Longint;
  dd: array[0..1000,0..1000] of Longint;
  vis: array[0..1000] of boolean;
  
begin
  assign(input,'joke.in'); reset(input);
  assign(output,'joke.out'); rewrite(output);
  read(n);
  fillchar(dd,sizeof(dd),0);
  fillchar(vis,sizeof(vis),false);
  for i := 1 to n do begin
    read(a[i],b[i]);
    inc(dd[a[i],b[i]]);
  end;

  best[0] := 0;
  for i := 1 to n do best[i] := n+1;

  for i := 0 to n-1 do begin
    for j := 1 to n do begin
      if i + j > n then break;
      aa := i;
      bb := n - i - j;
      if j <= dd[aa,bb] then begin
        dx := 0;
      end else dx := j - dd[aa,bb];
      if best[i+j] > best[i] + dx then begin
        best[i+j] := best[i] + dx;
        link[i+j] := i;
      end;
    end;
  end;

  write(best[n],' ');
  k := n;
  while k <> 0 do begin
    m := link[k];
    aa := m;
    bb := n - k;
    dx := k - m;
    for i := 1 to n do begin
      if dx = 0 then break;
      if vis[i] then continue;
      if (a[i] = aa) and (b[i] = bb) then begin
        vis[i] := true;
        dec(dx);
      end;
    end;
    k := m;
  end;

  for i := 1 to n do begin
    if not vis[i] then write(i,' ');
  end;
  writeln;
  close(input);
  close(output);
end.