This is my code… 
my answer
please help me…I have spent a lot of time on it. 
Sample test cases are not even running
Refer this
A simple 6-line code in Python will work fine 
My submission’s link:
https://www.codechef.com/viewsolution/28558958
You can also use Biginteger class of JAVA.
Refer this link: