What is {position held} of {Martin V} that is {replaced by} is {Eugene IV} ?
What position did Eugene IV take over from Martin V?
What position did Martin V hold that was eventually replaced by Eugene IV?
SELECT ?j WHERE { ?o property:replaced_by resource:Eugene_IV . ?o property:position_held ?j . resource:Martin_V property:position_held ?o }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q169612> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P39> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P1366> <http://wikidata.dbpedia.org/resource/Q167561>
} 

SELECT ?obj WHERE { wd:Q169612 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1366 wd:Q167561 }