Prolog: 4 exam task