title: Calculate the number of ways to color an N * M grid using K colors
body: <p>I wanna ask you how to calculate the number of ways to color an N * M grid using K colors. Adjacent squares in the grid should have different colors. Squares are considered adjacent if they share an edge. Is there a fast algorithm to do that? </p>