Imagine that you are in a store warehouse where you have just brought a new product - chains of different sizes and colors. The supplier treated his duties out of hand badly. All chains are mixed up, in this form they cannot be put up for sale, and first of all they need to be put in order. The chain must have links of the same color, so you must rearrange them at each level so that each chain gets links of its own color. You can only rearrange rings to a ring of the same color in the chain color sort.