program crivello;
uses crt;
var i,j,k,r,s:integer;
    a: array[1..160] of boolean;

begin
textbackground(white);
clrscr;
a[1]:=false;
for i:=2 to 160 do a[i]:=true;
k:=1;
s:=9;
textcolor (black);
for j:=1 to 11 do
   for i:=1 to 14 do
      begin
        gotoxy (i*5,j*2);
        write (k);
        k:=k+1;
      end;
      readln;
for k:=2 to 13 do
if a[k]=true then
begin
  r:=k;
  while r<161 do
  begin
    r:=r+k;
    a[r]:=false;
  end;
  r:=1;
  for j:=1 to 11 do
     for i:=1 to 14 do
      begin
        textcolor(s);
        gotoxy (i*5,j*2);
        if ((r<>k) and (r mod k=0)) then write (r);
        r:=r+1;
      end;
   s:=s+1;
   readln
end;
end.