{.$define debug}

{$apptype console}

{$ifdef debug}
{$R+,S+,Q+,I+,O-}
{$else}
{$R+,S-,Q+,I-,O+}
{$endif}

{$assertions on}
{$apptype console}

program template;
uses
 SysUtils;
const
 nmax = 1100;
 {$ifdef debug}
 cinfile = 'input.txt';
 coutfile = 'output.txt';
 {$else}
 cinfile = 'joke.in';
 coutfile = 'joke.out';
 {$endif}
type
 int = longint;
 real = extended;
 tTurtle = record
  a,b :int;
 end; 
var
 n :int;
 p :array [1..nmax] of tTurtle;
 number :array [1..nmax] of int;

 good :array [1..nmax] of boolean;

 np :array [1..nmax] of tTurtle;
 count :array [1..nmax] of int;
 w :array [1..nmax] of int;
 gr :array [1..nmax,1..nmax] of boolean;
 d :array [1..nmax] of int;
 prev :array [1..nmax] of int;
 used :array [1..nmax] of boolean;
 maxCount :int;
 k :int;
 ans :int;

procedure init;
begin
 fillchar (n,integer(@ans) - integer(@n),0);
 ans := 0;
 RandSeed := 234234;
end;

procedure readdata;
var i,j :int;
begin
 assign (input,cinfile);
 reset (input);
 read (n);
 for i := 1 to n do
  begin
   read (p[i].a,p[i].b);
   number[i] := i;
  end;
 close (input);
end;

procedure outdata;
var i,j :int;
begin
 assign (output,coutfile);
 rewrite (output);
 write (n - maxCount,' ');
 for i := 1 to n do
  if not good[i] then
   write (number[i],' ');
 writeln;   
 close (output);
end;

function less (const u,v :tTurtle):boolean;
begin
 if (u.a = v.a) then
  result := u.b < v.b
 else
  result := u.a < v.a;
end;

procedure swap (var a,b :tTurtle);
var tmp :tTurtle;
begin
 tmp := a;
 a := b;
 b := tmp;
end;

procedure swapInt (var a,b :int);
var tmp :int;
begin
 tmp := a;
 a := b;
 b := tmp;
end;

procedure sort (l,r :int);
var i,j :int;
    x :tTurtle;
begin
 i := l;
 j := r;
 x := p[l + random(r-l+1)];
 repeat
  while (less(p[i],x)) do
   inc(i);
  while (less(x,p[j])) do
   dec(j);
  if i <= j then
   begin
    swap (p[i],p[j]);
    swapInt(number[i],number[j]); 
    inc (i);
    dec(j);
   end;
 until i > j;
 if l < j then
  sort (l,j);
 if i < r then
  sort (i,r);
end;

function isRib (u,v :tTurtle):boolean;
begin
 result := false;
 if (u.a + u.b >= n) then
  exit;
 if (v.a + v.b >= n) then
  exit;
 if (u.b < v.b) then
  exit;
 result := (u.b >= (n - v.a)) and (v.a >= (n - u.b));
end;

function min (a,b :int):int;
begin
 if a < b then
  result := a
 else
  result := b;
end;

procedure addTurtle (v :tTurtle);
var i :int;
begin
 for i := 1 to n do
  if not good[i] then
   if (p[i].a = v.a) and (p[i].b = v.b) then
    begin
     good[i] := true;
     exit;
    end;
 raise Exception.Create('');
end;

procedure solve;
var i,j :int;
    cur :int; 
begin
 sort (1,n);
 k := 1;
 np[1] := p[1];
 count[1] := 1;
 for i := 2 to n do
  if (p[i].a = p[i-1].a) and (p[i].b = p[i-1].b) then
   inc (count[k])
  else
   begin
    inc (k);
    np[k] := p[i];
    count[k] := 1;
   end;
 for i := 1 to k do
  w[i] := min (count[i],n - np[i].a - np[i].b);
 for i := 1 to k-1 do
  for j := i+1 to k do
   gr[i,j] := isRib(np[i],np[j]);
 for i := k downto 1 do
  begin
   d[i] := w[i];
   prev[i] := 0;
   for j := k downto i+1 do
    if gr[i,j] then
     if d[i] < d[j] + w[i] then
      begin
       d[i] := d[j] + w[i];
       prev[i] := j;
      end;
  end;
 cur := 0;
 for i := 1 to k do
  if d[i] > maxCount then
   begin
    maxCount := d[i];
    cur := i;
   end;
 while (cur <> 0) do
  begin
   used[cur] := true;
   cur := prev[cur];
  end;
 for i := 1 to k do
  if used[i] then
   for j := 1 to w[i] do
    addTurtle(np[i]);  
end;

begin
 init;
 readdata;
 solve;
 outdata;
end.
