45. Use $m(m \geqslant 2)$ colors to paint a $1 \times n$ chessboard $(n \geqslant m)$, each cell painted with one color, find the number of coloring methods such that adjacent cells have different colors, the first and last cells also have different colors, and each color is used at least once.
45. $\sum_{k=0}^{m}(-1)^{m-k}\binom{m}{k}\left[(k-1)^{n}+(-1)^{n}(k-1)\right]$.