what is the {replaced by} for {Livorno} has {head of government} as {Nicola Badaloni} ?
Who replaced Nicola Badaloni as the Livorno head of state?
What { replaced } for { Livorno } has { head of government } like { Nicola Badaloni }?
SELECT ?u WHERE { ?d property:replaced_by ?u . ?d property:head_of_government resource:Nicola_Badaloni . resource:Livorno property:head_of_government ?d }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q6761> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P6> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q3876122> .
?statement <http://www.wikidata.org/entity/P1366> ?value. 
} 

SELECT ?value WHERE { wd:Q6761 p:P6 ?s . ?s ps:P6 wd:Q3876122 . ?s pq:P1366 ?value}