The solution depends on what n is congruent to, when taken modulo 3.
Suppose n is congruent to 0 modulo 3, then consider
Since w is a root of unity, we have w^3=1 and thus trivially 1+w+w^2=0.
So factorising the above expression, we acquire
Which is equal to 0 and thus by raising it to the m'th power, we have 0 still.
Similarly to above, all terms fully factorised are eliminated, leaving the term 1 since w^3=1 implies w^k, where k is 0 modulo 3, is 1. Again, raising this to the m'th power preserves the term.
Now taking the case when n is 2 modulo 3, which is a little more tricky now, we reduce the given expression to (1+w)^m. Taking the Binomial Expansion, we have C(m,0)+C(m,1)*w+C(m,2)*w^2+...+C(m,m)*w^m
Again, we have to consider the possible cases for distinct terms taking m to be congruent to either 0, 1 or 2 modulo 3, then you can add them all up.