8. (10 points) Let $A$ be a $p \times p$ idempotent matrix and let $B$ be a $p \times p$ tripotent matrix. That is

$$A = A^2 \text{ and } B = B^3.$$

Find the all possible eigenvalues of $A$ and $B$.