A cube is painted yellow on the top and bottom, black on the front and back, and red on the left and right faces. It is then cut into 125 identical small cubes.
How many small cubes have all three colours?
Given: n = 5.
Only the corner cubes touch three faces of different colours.
Answer: 8