Hackerrank: Large powers (TLE on last 5 test cases)