select distinct ?x ?p1 ?p2 where { ?x . ?y . ?z . ?x ?p1 ?z. ?z ?p2 ?y. ?x ?y. }