prefix : prefix mon: select ?C ?BC ?P1 ?P2 ?X from from from from #from ## a small test setting from ## europe is more than sufficient =:( from where {# {?BC a :BigCity} UNION {?X a mon:Country; mon:carCode ?C; mon:hasCity ?BC . ?BC a :BigCity} UNION {?P1 a :ProvinceWithBigCity} UNION {?P2 a :ProvinceWithTwoBigCities} UNION {?X a :CountryWithTwoBigCities}}