WA on test #10.
Code for problem 407A.