Solution (source code)

= Solution

Let $0\ne U\subseteq W$ be a subrepresentation and choose
$$
0\ne u=\sum_{r=p}^q a_rw_r\in U
$$
with finite support. The $h$-eigenvalues $a+2r$ are pairwise distinct. By <Lagrange interpolation polynomial>[Lagrange interpolation], there is a polynomial $P$ which is one at one chosen eigenvalue appearing in $u$ and zero at all the others. Then $P(h)u$ is a nonzero scalar multiple of one basis vector $w_i$. Since $U$ is invariant under $h$, it contains $w_i$.