WA on test #33.
Code for problem 3D.