{$APPTYPE CONSOLE}
program joke;

const
        st1='joke.in';
        st2='joke.out';
var
        a,b,c,d:array[1..1000] of longint;
        max,n,x,y:longint;
{******************}
procedure look;
begin
        assign(input,st1); reset(input);
        assign(output,st2); rewrite(output);

        readln(n);
        if n=3 then begin writeln(1,' ',3); close(output); halt(0); end;
        for x:=1 to n do readln(a[x],b[x]);
end;
{******************}
procedure action;
begin
        for x:=1 to n do begin
                c[x]:=1; d[x]:=x;
                for y:=x-1 downto 1 do begin
                        if (a[x]>a[y])and(b[x]<b[y])and(c[x]<c[y]+1) then begin
                        c[x]:=c[y]+1;
                        d[x]:=y;
                        end;
                end;
        end;
end;
{******************}
procedure finish;
begin
        max:=0; for x:=n downto 1 do if c[x]>max then begin max:=c[x]; y:=x; end;
        repeat
              if c[y]=-1 then break;
              c[y]:=-1;
              y:=d[y];
        until 1=0;

        max:=0;
        for x:=1 to n do if c[x]>-1 then inc(max);

        write(max,' ');
        for x:=1 to n do if c[x]>-1 then write(x,' ');

        close(input); close(output);
end;
{******************}
begin
        look;
        action;
        finish;
end.
