Solution working locally. WA on SPOJ

Signed-off-by: Vineel Kumar Reddy Kovvuri <vineelkumarreddy@gmail.com>