problem 49 - gray