Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.

&nbsp;
Example 1:

Input: a = 2, b = [3]
Output: 8


Example 2:

Input: a = 2, b = [1,0]
Output: 1024


Example 3:

Input: a = 1, b = [4,3,3,8,5,2]
Output: 1


&nbsp;
Constraints:


	1 &lt;= a &lt;= 231 - 1
	1 &lt;= b.length &lt;= 2000
	0 &lt;= b[i] &lt;= 9
	b does not contain leading zeros.


class Solution:
    def superPow(self, a: int, b: List[int]) -> int:
        mod = 1337
        ans = 1

        for power in b:
            ans = ((pow(ans,10)%mod)*(pow(a,power)%mod))%mod

        return ans
import java.math.BigInteger;
class Solution {
    public int superPow(int a, int[] b) {
        StringBuilder bigNum = new StringBuilder();
        Arrays.stream(b).forEach(i -> bigNum.append(i));
        
        return 
            BigInteger.valueOf(a)
            .modPow(new BigInteger(bigNum.toString()), BigInteger.valueOf(1337))
            .intValue();
    }
}
class Solution {
public:
    int binaryExp(int a, int b, int M)
    {
        int ans = 1;
        a %= M;
        while(b)
        {
            if(b&1) ans = (ans * a)%M;
            a = (a*a)%M, b = b>>1;
        }
        return ans;
    }
    
    int superPow(int a, vector<int>& b) {
        int bmod = 0;
        for(auto it : b)
        {
            bmod = (bmod * 10 + it)%1140;
        }
        
        return binaryExp(a, bmod, 1337);
    }
};
var superPow = function(a, b) {
    const MOD = 1337;
    const pow = (num, n) => {
        let result = 1;
        for (let index = 0; index < n; index++) {
            result = result * num % MOD;
        }
        return result;
    };

    return b.reduceRight((result, n) => {
        a %= MOD;
        const powNum = result * pow(a, n) % MOD;

        a = pow(a, 10);
        return powNum;
    }, 1);
};
Super Pow