Roses and pots (1) P88410


Statement
 

pdf   zip

html

You have roses of three different colors. In particular, you have n roses of each color. Please print all the ways to plant all the roses in a line of 3n pots, one rose per pot, in such a way that there is exactly one pair of adjacent roses of the same color. The roses of the same color are indistinguishable.

Input

Input consists of several cases, each with n. Assume 1 ≤ n ≤ 6.

Output

For every case, print all the solutions in lexicographical order. Use numbers starting at one to identify each color. Print a line with 10 asterisks after every case.

Public test cases
  • Input

    1
    2
    

    Output

    **********
    112323
    113232
    121233
    121332
    122313
    123312
    123321
    131223
    131322
    132213
    132231
    133212
    211323
    212133
    212331
    213312
    213321
    221313
    223131
    231123
    231132
    232113
    232311
    233121
    311232
    312213
    312231
    313122
    313221
    321123
    321132
    322131
    323112
    323211
    331212
    332121
    **********
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++