What is {position held} of {Rutherford B. Hayes} that is {replaces} is {Ulysses S. Grant} ?
In what office did Rutherford B. Hayes replace Ulysses S. Grant?
Rutherford B. Hayes replaced Ulysses S. Grant in what office?
SELECT ?u WHERE { ?f property:position_held ?u . resource:Rutherford_B._Hayes property:position_held ?f . ?f property:replaces resource:Ulysses_S._Grant }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q35686> .
?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/P1365> <http://wikidata.dbpedia.org/resource/Q34836>
} 

SELECT ?obj WHERE { wd:Q35686 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1365 wd:Q34836 }