I tried to modify code for overflow problem but i am getting WA https://www.codechef.com/viewsolution/21628610