import itertools
if __name__ == '__main__':
l = ['a', 'b', 'c', 'd', 'e']
m = ['A', 'B', 'C']
with open("sample.csv", 'w') as f:
for n in range(1, len(l)):
element = list(itertools.combinations(l, n))
for a in itertools.product(m, element):
output = ','.join(x for b in a for x in b)
print(output)
f.write(output + '\n')
aW1wb3J0IGl0ZXJ0b29scwoKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzoKICAgIGwgPSBbJ2EnLCAnYicsICdjJywgJ2QnLCAnZSddCiAgICBtID0gWydBJywgJ0InLCAnQyddCiAgICB3aXRoIG9wZW4oInNhbXBsZS5jc3YiLCAndycpIGFzIGY6CiAgICAgICAgZm9yIG4gaW4gcmFuZ2UoMSwgbGVuKGwpKToKICAgICAgICAgICAgZWxlbWVudCA9IGxpc3QoaXRlcnRvb2xzLmNvbWJpbmF0aW9ucyhsLCBuKSkKICAgICAgICAgICAgZm9yIGEgaW4gaXRlcnRvb2xzLnByb2R1Y3QobSwgZWxlbWVudCk6CiAgICAgICAgICAgICAgICBvdXRwdXQgPSAnLCcuam9pbih4IGZvciBiIGluIGEgZm9yIHggaW4gYikKICAgICAgICAgICAgICAgIHByaW50KG91dHB1dCkKICAgICAgICAgICAgICAgIGYud3JpdGUob3V0cHV0ICsgJ1xuJykK