Initial version - WA on test #7.
Second version - WA on test #11.
Code for problem 340E.