There is a parade marching through a city! There are 3 main groups of marchers: the (B)and, Poster (C)arriers, and (F)lag Holders. Also, every (P)oliceman in the whole city is on duty.
Flag holders (F) can march anywhere in the parade, but two flag holders cannot march next to each other, unless three or more flag holders are together.
The band (B) has to be together. The poster carriers (C) all have to be behind the band (either together, or in two groups).
Given the number of flag holders, poster carriers, band members, and policemen separated by your choice of delimiter, print one line for every possible configuration, organized in alphabetical order.
Test case 1:
Input: 2 2 2 0 Output: CCFBBF CFCBBF CFCFBB FCCBBF FCCFBB FCFCBB
Test case 2:
Input: 3 3 3 0 Output: CCCBBBFFF CCCFFFBBB CCFCFBBBF CCFFFCBBB CFCCFBBBF CFCFCBBBF CFFFCCBBB FCCCFBBBF FCCFCBBBF FCFCCBBBF FCFCFCBBB FFFCCCBBB
Test case 3:
Input: 2 2 2 1 Output: CCBBFPF CCFBBFP CCFBBPF CCFPBBF CCFPFBB CCPFBBF CFCBBFP CFCBBPF CFCFBBP CFCFPBB CFCPBBF CFCPFBB CFPCBBF CFPCFBB CFPFCBB CPCFBBF CPFCBBF CPFCFBB FCCBBFP FCCBBPF FCCFBBP FCCFPBB FCCPBBF FCCPFBB FCFCBBP FCFCPBB FCFPCBB FCPCBBF FCPCFBB FCPFCBB FPCCBBF FPCCFBB FPCFCBB FPFCCBB PCCFBBF PCFCBBF PCFCFBB PFCCBBF PFCCFBB PFCFCBB
This is code-golf, so the shortest source code in bytes wins.
*Note: It doesn't count if it takes longer than 3 seconds to run each test case. I won't use integers more than 20.