prefix rdfs: select ?X # ?Y ?Z from from from from where {#{?Y a } UNION {?Z a } UNION { rdfs:subClassOf ?X}}