program ancestor2(output);
{ancestor algorithm using sets instead of boolean matrix}
r: array [1..n] of set of 1..n;
begin { j in r[i] = "i is a parent of j"}
if i mod 10 <> 0 then r[i] := [i+1] else r[i] := [];
if j in r[i] then write('1') else write('.');