program pj;

uses math; 

const infile  = 'joke.in';
      outfile = 'joke.out';
      maxn    = 1000;

var a, b, l, r : array[1..maxn]of longint;
    t : array[0..maxn]of longint;
    otr : array[1..maxn]of record l, r, w : longint end;
    cnt : array[1..maxn]of longint;
    uo, use : array[1..maxn]of byte;
    best : array[0..maxn]of record bv, l, q : longint end;
    n, m, ff : longint;

procedure init;
var i : longint;
 begin
  assign(input, infile); reset(input);
  assign(output, outfile); rewrite(output);
  read(n);
  fillchar(uo, sizeof(uo), 0);
  for i := 1 to n do begin
    read(a[i], b[i]);
    l[i] := a[i] + 1;
    r[i] := n - b[i];
   end; 
 end;

procedure solve;
var i, j, y : longint;
 begin
  for i := 1 to n do t[i] := i;
  for i := 1 to n - 1 do
   for j := i + 1 to n do
    if (r[t[i]] > r[t[j]]) or ((r[t[i]] = r[t[j]]) and (l[t[i]] > l[t[j]])) then begin
     t[0] := t[i]; t[i] := t[j]; t[j] := t[0];
    end;
  y := 1;
  m := 0;
  for i := 2 to n do
   if (l[t[i]] = l[t[i - 1]]) and (r[t[i]] = r[t[i - 1]]) then y := y + 1 else begin
     m := m + 1;
     otr[m].l := l[t[i - 1]];
     otr[m].r := r[t[i - 1]];
     otr[m].w := min(y, otr[m].r - otr[m].l + 1);
     y := 1;
    end;
  m := m + 1;                   
  otr[m].l := l[t[n]];
  otr[m].r := r[t[n]];
  otr[m].w := min(y, otr[m].r - otr[m].l + 1);
  for i := 0 to maxn do begin
    best[i].bv := 0;
    best[i].q := -1;
   end;
  for j := 1 to m do 
   for i := 0 to otr[j].l - 1 do
    if best[i].bv + otr[j].w > best[otr[j].r].bv then begin
       best[otr[j].r].bv := best[i].bv + otr[j].w;
       best[otr[j].r].l := i;
       best[otr[j].r].q := j;
      end;
  y := 1;
  for i := 2 to maxn do if best[i].bv > best[y].bv then y := i;
  while best[y].q <> -1 do begin
    uo[best[y].q] := 1;
    y := best[y].l;
   end;
  for i := 1 to m do if uo[i] = 0 then cnt[i] := 0 else cnt[i] := otr[i].w;
  fillchar(use, sizeof(use), 0);
  ff := 0;
  for i := 1 to n do
   for j := 1 to m do if cnt[j] > 0 then
    if (l[i] = otr[j].l) and (r[i] = otr[j].r) then begin
      cnt[j] := cnt[j] - 1;
      use[i] := 1;
      ff := ff + 1;
     end;
 end;

procedure save;
var i : longint;
 begin
  write(n - ff);
  for i := 1 to n do if use[i] = 0 then write(' ', i);
  writeln;
  close(output);
 end;

begin
 init;
 solve;
 save;
end.