:- use_module(library(clpfd)).

main :-
    read_num(N),
    NPlusOne is N + 1,
    print_f(NPlusOne, 1).

print_f(N, N).
print_f(N, Index) :-
        f(Index, Len),
        write(Len),
        nl,
        NewIndex is Index + 1,
        print_f(N, NewIndex).

f(N, Len) :-
        1 #=< X,
        1 #=< Y,
        1 #=< Z,

        X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X #= N,
        
        findall(_, label([X, Y, Z]), All),
        length(All, Len).
f(_, 0).


read_str(S) :-
        read_string(current_input, ' \n', '', _, S).
 
read_num(N) :-
	read_str(S),
	number_string(N, S).
