query: PREFIX wikibase: <http://wikiba.se/ontology#>
  PREFIX wd: <http://www.wikidata.org/entity/> 
  PREFIX wdt: <http://www.wikidata.org/prop/direct/>
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  
  SELECT ?h ?spouse ?gender WHERE {
     ?h wdt:P21 ?gender .
     ?h wdt:P26 ?spouse .
     ?spouse wdt:P21 ?genderr .
     FILTER (?gender = ?genderr)
   } LIMIT 1000