Υǥ쥯ȥκ

(N,LL) :-
        findall(L,(N,L),LL).

(N,X) :-
        findall(M,for(1,M,N),L),
        (L,N,X).

(Y,N,X) :-
        (Y,N,1,X).

(Y,0,_,[]).
(Y,N,S1,[A|X]) :-
        del(Z = Y - A),
        \+(A = S1),
        M is N - 1,
        S2 is S1 + 1,
        (Z,M,S2,X).

del(X = [A|X] - A).
del([B|Y] = [B|X] - A) :-
        del(Y = X - A).