<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def generate(regex, Ns):
    "Return the strings matching regex whose length is in Ns."
    return sorted(regex_parse(regex)[0](Ns),
                  key=lambda s: (len(s), s))