PROGRAM NYOLC_KIRALYNO(OUTPUT);
VAR I:INTEGER;
    A:ARRAY[1..8] OF BOOLEAN;
    B:ARRAY[2..16] OF BOOLEAN;
    C:ARRAY[-7..7] OF BOOLEAN;
    X:ARRAY[1..8] OF INTEGER;

PROCEDURE NYOMTAT;
VAR K:INTEGER;
BEGIN
    FOR K:= 1 TO 8 DO WRITE(X[K]:4);
    WRITELN;
END;

PROCEDURE PROBAL(I:INTEGER);
VAR J:INTEGER;
BEGIN
   FOR J:= 1 TO 8 DO
       IF A[J] AND B[I+J] AND C[I-J] THEN
          BEGIN
             X[I] := J;
             A[J] := FALSE; B[I+J] := FALSE; C[I-J] := FALSE;
             IF I<8 THEN PROBAL(I+1) ELSE NYOMTAT;
             A[J] := TRUE; B[I+J] := TRUE; C[I-J] := TRUE;
          END;
END;

BEGIN
   FOR I:= 1 TO 8 DO A[I] := TRUE;
   FOR I:= 2 TO 16 DO B[I] := TRUE;
   FOR I:= -7 TO 7 DO C[I] := TRUE;
   PROBAL(1);
END.