What is {contains administrative territorial entity} of {German Confederation} that is {end time} is {1866-1-1} ?
Give me the name of territorial entity that separated from German Confederation in 1866?
What territorial entity of the German Confederation ended in 1866?
SELECT ?q WHERE { ?i property:end_time ?x . resource:German_Confederation property:contains_administrative_territorial_entity ?i . ?i property:contains_administrative_territorial_entity ?q . FILTER ( CONTAINS ( YEAR ( ?x ) , '1866' ) ) }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q151624> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P150> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P582> <1866-1-1>
} 

SELECT ?obj WHERE { wd:Q151624 p:P150 ?s . ?s ps:P150 ?obj . ?s pq:P582 ?x filter(contains(YEAR(?x),'1866')) }