Q:

Periodicity of states in Markov Chain

Determine the classes and the periodicity of the various states for a
  Markov Chain with transition probability matrix
  $$P=\begin{bmatrix}0&0&1&0\\1&0&0&0\\\frac{1}{2}&\frac{1}{2}&0&0\\\frac{1}{3}&\frac{1}{3}&\frac{1}{3}&0\end{bmatrix}$$

I'm not so sure, but from what I'm understand to find the classes of states, is enough see which states communicate each other, so I think that classes are {0}, {1,2}, {3}.
I looked in my book, and I saw that in some instance they just did the decomposition of matrix in blocks, though I did not understand the logic behind such decomposition, someone explain to me how this is done?
Proceeding, I know that if $i\leftrightarrow j$ then $d(i)=d(j)$ where $d$ denote the period of state. Then I just need to find the periods of state $i=0,1,3$, in the book they say

We define the period of state $i$, written $d(i)$, to be the greatest
  common divisor (g.c.d) of all integers $n\geq 1$ for which
  $P_{ii}^n>0$

I looked this definition several times, but I still do not understand how to apply it, how can I do this?

A:

Assuming that the states are $0,1,2$, and $3$, we see the system can take the paths
$$0 \to 2 \to 0,$$
$$0 \to 2 \to 1 \to 0,$$
so $\{0,1,2\}$ is a communication class with period $\gcd(2,3) = 1$. State 3 does not have a period since the probability of ever reaching 3 is 0.

