%%% 04.02.2013

%% Task 2
% X - list of lists

%% is_member(E, L) :- E is a member of L
is_member(H, [H|_]).
is_member(H, [_|T]) :- is_member(H, T).

%% last_element(E, L) :- e is the last element of L
last_element(E, [_|[E]]).
last_element(E, [_|T]) :- last_element(E, T).

p(L) :- not((
			 is_member(X, L), is_member(Y, L),
			 not((
			 	  not(last_element(X, L)),
			 	  is_member(E, X),
			 	  is_member(E, Y)
			 	))
		   )).

% p([[1,2], [2,3], [3,4]]).