What should be the approach for this problem on SPOJ? Thank you. @galencolin @waqar_ahmad224 @hello_hell @carre @aneee004 .