Welcome to the world of SPOJ Solutions. Before looking at any solutions, first give it your best try and then no harm in looking at the solutions. Try to take ideas from solutions and then implement of your own, which will be of great help in long run.