Wrong answer when expected answer is 10^10(long long int)

I guess implicit typecasting is the problem but cannot understand where. Please help?

Link to Problem - https://www.hackerrank.com/challenges/journey-to-the-moon/problem

Link to my solution (line 55 - 60)- https://ide.codingblocks.com/s/402900

Wrong test case -

100000 2

1 2
3 4

Wrong answer - 704982702 (9 digits)

Expected answer - 4999949998 (10 digits)

Pics are attached. Thanks in advance.