2. There is a cube fixed on legs, and six different paints. In how many ways can all the faces of the cube be painted (each in one color, not all paints have to be used) so that adjacent faces (having a common edge) are of different colors? (16 points)
Solution. Let's consider 4 cases of coloring a cube.

1) The top and bottom faces are the same color, and the left and right faces are the same color. We choose the color for the top and bottom faces in 6 ways, then the color for the left and right faces in 5 ways, then the color for the front face in 4 ways, and the color for the back face in 4 ways. In total, $6 \cdot 5 \cdot 4 \cdot 4=480$ ways.
2) The top and bottom faces are the same color, and the left and right faces are different colors. We choose the color for the top and bottom faces in 6 ways, then the color for the left face in 5 ways, then the color for the right face in 4 ways, then the color for the front face in 3 ways, and the color for the back face in 3 ways.

In total, $6 \cdot 5 \cdot 4 \cdot 3 \cdot 3=1080$ ways.

3) The top and bottom faces are different colors, and the left and right faces are the same color. We choose the color for the left and right faces in 6 ways, then the color for the top face in 5 ways, then the color for the bottom face in 4 ways, then the color for the front face in 3 ways, and the color for the back face in 3 ways.

In total, $6 \cdot 5 \cdot 4 \cdot 3 \cdot 3=1080$ ways.

4) The top and bottom faces are different colors, and the left and right faces are different colors. We choose the color for the top face in 6 ways, then the color for the bottom face in 5 ways, then the color for the left face in 4 ways, then the color for the right face in 3 ways, then the color for the front face in 2 ways, and the color for the back face in 2 ways.

In total, $6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 2=1440$ ways.

Finally, we have $480+1080+1080+1440=4080$.

## Answer: 4080.