{حزورة صعبة جدا وهذا حلها وهي
	   #
	 #15#
	#19#14#
	 #21#
	  #}
program mat;
var i1,i2,i3,i4,i5,i6,i7,i8,i9:integer;
begin
for i1:=1 to 9 do
   begin
   for i2:=1 to 9 do
        begin
	if i2=i1 then continue;
	for i3:=1 to 9 do
	    begin
	    if (i3=i2) or (i3=i1) then continue;
	    for i4:=1 to 9 do
		begin
		if (i4=i1) or (i4=i2) or (i4=i3) then continue;
		if i1+i2+i3+i4<>14 then continue;
		for i5:=1 to 9 do
		     begin
		     if (i5=i1) or (i5=i2) or (i5=i3) or (i5=i4) then continue;
		     for i6:=1 to 9 do
			  begin
                          if (i6=i1) or (i6=i2) or (i6=i3) or (i6=i4) or (i6=i5) then continue;
			  if i1+i5+i6+i4<>21 then continue;
			   for i7:=1 to 9 do
		                begin
				if (i7=i1) or (i7=i2) or (i7=i3) or (i7=i4) or (i7=i5) or (i7=i6) then continue;
				for i8:=1 to 9 do
				     begin
				     if (i8=i1) or (i8=i2) or (i8=i3) or (i8=i4) or (i8=i5) or (i8=i6) or (i8=i7) then continue;
				     if i8+i5+i1+i7<>19 then continue;
				     for i9:=1 to 9 do
					begin
					if (i9=i1) or (i9=i2) or (i9=i3) or (i9=i4) or (i9=i5) or (i9=i6) or (i9=i7) or (i9=i8) then continue;
				      	if i8+i1+i2+i9<>15 then continue;
                                        writeln(i1,' ',i2,' ',i3,' ',i4,' ',i5,' ',i6,' ',i7,' ',i8,' ',i9);
                                        end;
                                     end;
                                end;
                           end;
                     end;
                end;
            end;
        end;
   end;
end.