Solutions To The Problem on SPOJ