what is the {statement is subject of} for {Costa Rica} has {shares border with} as {Panama} ?
What area does Costa Rica and Panama share a border?
What part of Costa Rica shares a border with Panama?
SELECT ?c WHERE { ?z property:shares_border_with resource:Panama . ?z property:statement_is_subject_of ?c . resource:Costa_Rica property:shares_border_with ?z }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q800> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P47> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q804> .
?statement <http://www.wikidata.org/entity/P805> ?value. 
} 

SELECT ?value WHERE { wd:Q800 p:P47 ?s . ?s ps:P47 wd:Q804 . ?s pq:P805 ?value}