{$DEFINE DEBUG}

{$IFDEF DEBUG}
{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$ELSE}
{$A+,B-,C+,D-,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$ENDIF}

{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $02000000}
{$APPTYPE CONSOLE}

uses
  Math, SysUtils;

type
  int = longint;
  float = extended;

const
  maxn = 1100;
  cin_file = 'joke.in';
  cout_file = 'joke.out';
  eps : float = 1e-9;
  fmax : float = 1e40;
  besk = $3F3F3F3F;

type
  tturtle = record
    a, b, idx : int;
  end;
  tgroup = record
    a, b, k, idx : int;
  end;

var
  n, ng : int;
  a : array[1..maxn] of tturtle;
  g : array[1..maxn] of tgroup;
  d : array[0..maxn, 0..maxn] of boolean;
  from_i, from_j, from_g, from_k : array[0..maxn, 0..maxn] of int;
  good : array[1..maxn] of boolean;

procedure swapT(var a, b : tturtle);
var
  t : tturtle;
begin
  t := a;
  a := b;
  b := t;
end;

procedure solve;
var
  i, j, c, c1, k, l, ni, nj : int;
begin
  read(n);

  for i := 1 to n do
  begin
    read(a[i].a, a[i].b);
    a[i].idx := i;
  end;

  for i := 1 to n do
    for j := i + 1 to n do
      if (a[j].a < a[i].a) or ((a[j].a = a[i].a) and (a[j].b < a[i].b)) then swapT(a[i], a[j]);

  fillchar(g, sizeof(g), 0);
  ng := 0;
  for i := 1 to n do
  begin
    if (ng = 0) or (a[i].a <> g[ng].a) or (a[i].b <> g[ng].b) then
    begin
      inc(ng);
      g[ng].a := a[i].a;
      g[ng].b := a[i].b;
      g[ng].idx := a[i].idx;
    end;
    inc(g[ng].k);
  end;

  fillchar(d, sizeof(d), 0);
  d[0, 0] := true;

  fillchar(from_i, sizeof(from_i), 0);
  fillchar(from_j, sizeof(from_j), 0);
  fillchar(from_g, sizeof(from_g), 0);
  fillchar(from_k, sizeof(from_k), 0);

  c := 1;
  for i := 0 to n - 1 do
  begin
    while (c <= ng) and (g[c].a < i) do inc(c);
    c1 := c - 1;
    while (c1 < ng) and (g[c1 + 1].a = i) do inc(c1);
    for j := 0 to n do
      if (d[i, j]) then
      begin
        if (j < n) then
        begin
          d[i + 1, j + 1] := true;
          from_i[i + 1, j + 1] := i;
          from_j[i + 1, j + 1] := j;
          from_g[i + 1, j + 1] := 0;
          from_k[i + 1, j + 1] := 0;
        end;
        for l := c to c1 do
          for k := 1 to g[l].k do
          begin
            ni := n - g[l].b;
            nj := j + n - g[l].b - i - k;
            if (i + k <= ni) and (nj <= n) then
            begin
              d[ni, nj] := true;
              from_i[ni, nj] := i;
              from_j[ni, nj] := j;
              from_g[ni, nj] := l;
              from_k[ni, nj] := k;
            end;
          end;
      end;
    c := c1 + 1;
  end;
  i := n;
  j := 0;
  while (not d[i, j]) do inc(j);

  fillchar(good, sizeof(good), 0);

  while (i > 0) do
  begin
    ni := from_i[i, j];
    nj := from_j[i, j];

    if (from_g[i, j] <> 0) then
    begin
      for c := 1 to from_k[i, j] do
        good[g[from_g[i, j]].idx + c - 1] := true;
    end;

    i := ni;
    j := nj;    
  end;

  k := 0;
  for i := 1 to n do
    if (not good[i]) then inc(k);
  write(k);

  for i := 1 to n do
    if (not good[i]) then write(' ', i);
end;

begin
  assign(input, cin_file);
  reset(input);
  assign(output,  cout_file);
  rewrite(output);

  solve;

  close(input);
  close(output);
end.