connect(CityA,CityB,List):- flight(CityA,CityB), append([CityA],[CityB],List). connect(CityA,CityB,List):- flight(CityA,CityC), connect(CityC,CityB,Sublist), append([CityA],Sublist,List).