Nick has a $3 \times 3$ grid and wants to color each square in the grid one of three colors such that no two squares that are adjacent horizontally or vertically are the same color. Compute the number of distinct grids that Nick can create.

Let's think step by step and output the final answer within \boxed{}.
user