added code for Uva:11059, pathetic solution, did for AC only.