prefix rdf: prefix owl: prefix : select ?X ?Y ?Z from where {?X a rdf:List; rdf:first ?Y . OPTIONAL {?X rdf:rest ?Z}}