def firstitem(map, key=(lambda k, v: bool(k)), default=None, apply=(lambda k, v: (k, v))):
    return next((apply(k, v) for (k, v) in map if key(k, v)), default)
def firstitem(map, key=(lambda k, v: bool(k)), default=None, apply=(lambda k, v: (k, v))):
    return next((apply(k, v) for (k, v) in map if key(k, v)), default)