:- use_module(contestlib,[for/3]).
kay4(N) :-
for(X,1,N),
for(Y,1,N),
point_contains(X,Y,N,C),
write(C),
fail.
point_contains(1,1,_,C) :- !, C = a.
point_contains(1,N,N,C) :- !, C = 'b\n'.
point_contains(1,_,_,C) :- !, C = '-'.
point_contains(N,1,N,C) :- !, C = c.
point_contains(N,N,N,C) :- !, C = 'd\n'.
point_contains(N,_,N,C) :- !, C = '-'.
point_contains(_,1,_,C) :- !, C = '|'.
point_contains(_,N,N,C) :- !, C = '|\n'.
point_contains(X,Y,N,C) :-
(X =< N//2 ; (N - X) < N//2), !,
( X == Y ->
C = '\\'
; X + Y =:= N + 1 ->
C = '/'
;
C = ' '
).
point_contains(_,Y,N,C) :-
( Y =:= N//2 + 1 ->
C = 'X'
;
C = ' '
).