Elizur has an empty $n \times m$ grid and he wants to use some $1 \times 2$ and $2 \times 1$ dominoes to cover the entire grid. In the grid, each domino ought to cover exactly two adjacent squares and each square ought to be covered by exactly one domino, where two squares are adjacent if and only if they share a common side.
Obviously, he can achieve that if and only if at least one of $n$ and $m$ is even. In case that both $n$ and $m$ are odd, there is always a square that must be left empty. Hence, he intends to know in how many ways he can cover the entire grid. Two ways are considered different if and only if there exist two dominoes, each selected from one way, satisfying that they cover exactly one square at the same position.
Can you help him determine the answer? The answer may be exceedingly large, so he only requests you to tell him the answer modulo a prime number $p$.