Understanding a complex number proof that there is a convex equiangular $1990$-gon with sides $1^2$, $2^2$, $\ldots$, $1990^2$ IMO 1990, Problem B3 reads:

Prove that there exists a convex $1990$-gon such that all its angles are equal and the lengths of the sides are the numbers $1^2$, $2^2$, $\ldots$, $1990^2$ in some order.

I have an issue understanding the solution by Robin Chapman, reproduced here:
"In the complex plane we can represent the sides as $p_n^2w^n$, where $p_n$ is a permutation of $(1, 2, \ldots , 1990)$ and $w$ is a primitive $1990$th root of unity.
The critical point is that $1990$ is a product of more than $2$ distinct primes: $1990 = 2\cdot 5\cdot 199$. So we can write $w = -1\cdot a\cdot b$, where $-1$ is primitive $2$nd root of unity, $a$ is a primitive $5$th root of unity, and $b$ is a primitive $199$th root of unity.
Now given one of the $1990$th roots we may write it as $(-1)^ia^jb^k$, where $0 < i < 2$, $0 < j < 5$, $0 < k < 199$ and hence associate it with the integer $r(i,j,k) = 1 + 995i + 199j + k$. This is a bijection onto $(1, 2, \ldots , 1990)$. We have to show that the sum of $r(i,j,k)^2 (-1)^ia^jb^k$ is zero.
We sum first over $i$. This gives $-9952 \times \text{sum of $a^jb^k$}$ which is zero, and $-1990 \times \text{sum $s(j,k) a^jb^k$}$, where $s(j,k) = 1 + 199j + k$. So it is sufficient to show that the sum of $s(j,k) a^jb^k$ is zero. We now sum over $j$. The $1 + k$ part of $s(j,k)$ immediately gives zero. The $199j$ part gives a constant times $b^k$, which gives zero when summed over $k$."
I did not grasp the details of the solution well, especially how the summations are parted and computed. I would thank any body elucidating the solution in detail. 
 A: For the algebraic part (figuring out why the sum is zero) statement we actually use is as follows: let $m,n,p > 1$, $\alpha$,$\beta$,$\gamma$ respectively primitive $m$-roots, $n$-roots, and $p$-roots of unity.
Let $P(x,y,z)$ be a polynomial with degree at most $2$. 
Then $$\sum_{0 \leq i < m}\sum_{0 \leq j < n}\sum_{0 \leq k < p}P(i,j,k)\alpha^i\beta^j\gamma^k=0.$$
For the proof, we just need to show it when $P$ is a monomial, and since $P$ has degree $2$ we may without loss of generality assume that $P$ does not depend on $z$.
But then $$\sum_{0 \leq i < m}\sum_{0 \leq j < n}\sum_{0 \leq k < p}P(i,j,k)\alpha^i\beta^j\gamma^k=\sum_{0\leq i < m}\sum_{0 \leq j < n}\sum_{0 \leq k < p}P(i,j,0)\alpha^i\beta^j\gamma^k = \sum_{i,j}{f(i,j)}\sum_k{\gamma^k}=0,$$ since $\sum_{0 \leq k < p}{\gamma^k}=0$. 
To go back to the geometric aspect, for all $1 \leq i \leq 1990$, consider the triple $u(i)$ such that $(-1)^{u_1(i)}a^{u_2(i)}b^{u_3(i)}=\omega^i$ for a fixed primitive $1990$-th root of unity $\omega$, and $i \longmapsto r(u(i))$ is a permutation of $\{1,\ldots,1990\}$. Then define $z_0=0$ and for all $1 \leq i \leq 1990$, $z_i=z_{i-1}+r(u(i))^2\omega^i$. 
Then $z_{1990}=0$ and the polygon $z_1,\ldots,z_{1990}$ drawn in the complex plane, works. 
