I am trying to solve the Ising model for $4 \times 4$ square lattice without a magnetic field. The calculation involved evaluating the expression below,

After writing the code as
Z = (1+ t sigma_1 sigma_2)(1+ t sigma_2 sigma_3)(1+ t sigma_3 sigma_4)....(1+ t sigma_12 sigma_16)
I evaluate
Expand[Z]
Which gives a polynomial in t, which contains roughly 8 million terms. According to the Ising construction, only 512 terms should give non-zero contributions to the final result. The way to identify the non-zero contributions is to find coefficients of the even power of t such that all the sigma's in a given product have even power. For example
t^4 (sigma_1 sigma_2 sigma_5 sigma_6)^2
Simply put, the expression I am looking for looks like below

Where $\cdots$ are the terms containing even power in various $\sigma$. The problem is writing a piece of code which do this sorting.
I am not quite used to coding. Hope someone can help me to write code for this problem. Thanks in advance.