% define the predicate uptosecondcousin/2 to hold for two people if they are brothers/sistes or first or second cousins: uptosecondcousin(X, Y) :- parent(X, PX), parent(PX, GPX), parent(GPX, GGP), parent(GPY, GGP), parent(PY, GPY), parent(Y, PY), X != Y.