template describes a set of words made of lowercase English letters, following these rules:
- a single letter describes a one-word set: "q" → {q};
- curly braces holding one or more comma-separated templates describe the union of their sets: "{a,bc,a}" → {a, bc};
- templates written one after another describe every concatenation where the first piece comes from the first template's set and the second from the second's. For example, "{a,b}{c,d}" → {ac, ad, bc, bd}, and "m{e,a}t" → {met, mat}.
The rules can be nested to any depth.
Return every distinct word described by the template, in lexicographic order.template="{x,yz}{a,b}" → ['xa', 'xb', 'yza', 'yzb']Each word of the first group is joined with each word of the second: xa, xb, yza, yzb.
template="k{o,{o,i}t}" → ['kit', 'ko', 'kot']The inner part gives "ot" and "it", together with "o" that makes ko, kot, kit.
template="{a,b,a}" → ['a', 'b']Duplicates appear in the answer only once.
len(template) ≤ 60template consists of {, }, , and lowercase English letterstemplate is well formed under the rules abovetemplate="{x,yz}{a,b}"['xa', 'xb', 'yza', 'yzb']
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.