query: SELECT ?item ?qid ?P17 ?P17Label ?P495 ?P495Label WHERE {
    BIND( xsd:integer( STRAFTER( STR( ?item ), STR( wd:Q ) ) ) AS ?qid )
    ?item wdt:P31/wdt:P279* wd:Q107357104.
    OPTIONAL {?item wdt:P17 ?P17.} 
    OPTIONAL {?item wdt:P495 ?P495.} 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  } group by ?item ?P17 ?P17Label ?P495 ?P495Label ?qid ORDER BY ?qid