cifra(0).
cifra(1).
cifra(2).
cifra(3).
cifra(4).
cifra(5).
cifra(6).
cifra(7).
cifra(8).
cifra(9).

riporto(0).
riporto(1).

risolvi(A,B,C):-
	soluzione(A,B,C).





soluzione(A,B,C) :-
	cifra(D),
	cifra(U),
	cifra(E),
	cifra(S),
	cifra(I),
	cifra(O),
	cifra(T),
	riporto(R),
	riporto(R1),
        O is E + I - (10*R),
	T is U + E + R - (10*R1),
	T1 is D + S + R1,
	T is T1-10,
	O is 1,
	diversi(D,U,E,S,I,O,T),
	A is D*100+U*10+E,
	B is S*100+E*10+I,
	C is O*1000 + T*100 + T*10 + O,
	write(A),
	write(B),
	write(C).





diversi(D,U,E,S,I,O,T):-
	D =\= U,
        D =\= E,
	D =\= S,
	D =\= I,
	D =\= O,
	D =\= T,
        U =\= E,
	U =\= S,
	U =\= I,
	U =\= O,
	U =\= T,
	E =\= S,
	E =\= I,
	E =\= O,
	E =\= T,
	S =\= I,
	S =\= O,
	S =\= T,
	I =\= O,
	I =\= T,
	O =\= T.

