{$R+,Q+,O-}
{$MINSTACKSIZE $00404000}
{$APPTYPE CONSOLE}
type
  int = longint;

var
  n, i, j, a, b: int;
  x, y, tu, num, next: array[1..1000] of int;
  ans, link: array[0..1000] of int;
  take: array[0..1000] of boolean;
  len, z, bst, cur: int;


begin
  assign(input, 'joke.in');
  assign(output, 'joke.out');
  reset(input);
  rewrite(output);
  readln(n);
  len := 0;
  for i := 1 to n do
  begin
    read(a);
    readln(b);
    inc(a);
    b := n - b;
    if (a <= b) then
    begin
      j := 0;
      repeat
        inc(j);
      until (j > len) or ((x[j] = a) and (y[j] = b));
      if (j > len) then
      begin
        inc(len);
        x[len] := a;
        y[len] := b;
        num[len] := 1;
        tu[len] := i;
      end
      else if (num[j] < b + 1 - a) then
      begin
        next[i] := next[tu[j]];
        next[tu[j]] := i;
        inc(num[j]);
      end;
    end;
  end;
  bst := 0;
  for z := 1 to n do
  begin
    for i := 1 to len do if (y[i] <= z) then
    begin
      cur := ans[x[i] - 1] + num[i];
      if (cur > ans[z]) then
      begin
        ans[z] := cur;
        link[z] := i;
        if (ans[z] > ans[bst]) then
          bst := z;
      end;
    end;
  end;
  a := 0;
  while (bst > 0) do
  begin
    i := tu[link[bst]];
    while (i > 0) do
    begin
      inc(a);
      take[i] := true;
      i := next[i];
    end;
    bst := x[link[bst]] - 1;
  end;
  write(n - a);
  for i := 1 to n do if not take[i] then
    write(' ', i);
  writeln;
end.

