program j;

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

uses
  Math,
  SysUtils;

Type
  Integer=LongInt;
  Real=Extended;

Const
  TaskID='joke';
  InFile=TaskID+'.in';
  OutFile=TaskID+'.out';
  MaxN=1002;

Type
  TTurtle=Record
    A,B,ID:Integer;
  End;

Var
  N:Integer;
  T:Array[0..MaxN]Of TTurtle;
  Am:Array[0..MaxN]Of Integer;
  Good:Array[0..MaxN]Of Boolean;
  Res:Array[0..MaxN]Of Boolean;
  Best:Array[0..MaxN]Of Integer;
  Prev:Array[0..MaxN]Of Integer;
  RVal:Integer;
  RAt:Integer;

Procedure Load;
Var
  I:Integer;
Begin
  ReSet(Input,InFile);
  Read(N);
  For I:=1 To N Do Begin
    Read(T[I].A,T[I].B);
    T[I].ID:=I;
  End;
  Close(Input);
End;

Function Less(A,B:TTurtle):Boolean;
Begin
  Less:=(A.A<B.A) Or (A.A=B.A) And (A.B>B.B);
End;

Procedure Solve;
Var
  I,J:Integer;
  Tmp:TTurtle;
Begin
  For I:=1 To N-1 Do
    For J:=N DownTo I+1 Do
      If Less(T[J],T[J-1]) Then Begin
        Tmp:=T[J];
        T[J]:=T[J-1];
        T[J-1]:=Tmp;
      End;
  FillChar(Good,SizeOf(Good),True);
  FillChar(Res,SizeOf(Res),True);
  FillChar(Am,SizeOf(Am),0);
  J:=1;
  For I:=1 To N Do Begin
    If (T[I].A+T[I].B>N-1) Then Begin
      Good[I]:=False;
      Continue;
    End;
    If (I=1) Or (T[I-1].A<>T[I].A) Or (T[I-1].B<>T[I].B) Then J:=I;
    If I<>J Then Begin
      Good[I]:=False;
    End;
    Inc(Am[J]);
  End;
  T[0].A:=0;
  T[0].B:=N;
  T[0].ID:=0;
  Best[0]:=0;
  Prev[0]:=0;
  RVal:=0;
  RAt:=0;
  For I:=1 To N Do If Good[I] Then Begin
    Best[I]:=Am[I];
    Prev[I]:=0;
    For J:=1 To I-1 Do If Good[J] And (N-T[J].B<=T[I].A) Then Begin
      If Best[J]+Am[I]>Best[I] Then Begin
        Best[I]:=Best[J]+Am[I];
        Prev[I]:=J;
      End;
    End;
    If Best[I]>RVal Then Begin
      RVal:=Best[I];
      RAt:=I;
    End;
  End;
  I:=RAt;
  While I>0 Do Begin
    For J:=1 To Am[I] Do Res[T[I+J-1].ID]:=False;
    I:=Prev[I];
  End;
End;

Procedure Save;
Var
  I:Integer;
Begin
  ReWrite(Output,OutFile);
  Write(N-RVal);
  For I:=1 To N Do If Res[I] Then Write(' ',I);
  WriteLn;
  Close(Output);
End;

begin
  Load;
  Solve;
  Save;
end.
