program ancestor(output);
{R.W.Floyd: 'Ancestor', Comm.ACM 6-62 and 3-63, Alg.96}
r: array [1..n, 1..n] of boolean;
begin { r[i,j] = "i is a parent of j"}
for j := 1 to n do r[i,j] := false;
if i mod 10 <> 0 then r[i,i+1] := true;
if r[i,k] then r[j,k] := true;
for j := 1 to n do write(chr(ord(r[i,j])+ord('0')));