Write a program that, given four natural numbers , , and , prints all the multisets with numbers that can be made up with , in such a way that every number appears between and times.
Input consists of a natural number , followed by a natural number , followed by a natural number , followed by a natural number . Assume .
Print all the multisets of size that can be made up with , using each number between and times. The numbers inside each multiset must appear in non-decreasing order.
You can print the solutions to this exercise in any order.
Input
3 1 4 6
Output
{1,2,3,3,3,3}
{1,2,2,3,3,3}
{1,2,2,2,3,3}
{1,2,2,2,2,3}
{1,1,2,3,3,3}
{1,1,2,2,3,3}
{1,1,2,2,2,3}
{1,1,1,2,3,3}
{1,1,1,2,2,3}
{1,1,1,1,2,3}