import pywikibot
from pywikibot import pagegenerators as pg

query='select ?item where { ?item wdt:P131 ?entity . ?entity wdt:P31 wd:Q2039348 . OPTIONAL {?item wdt:P17 ?land } filter (!bound(?land))}'