':type a: int
:type b: List[int]
:rtype: int'

def superPow(self, a, b):

    def myPow(a, n, b):
        result = 1
        x = (a % b)
        while n:
            if (n & 1):
                result = ((result * x) % b)
            n >>= 1
            x = ((x * x) % b)
        return (result % b)
    result = 1
    for digit in b:
        result = ((myPow(result, 10, 1337) * myPow(a, digit, 1337)) % 1337)
    return result
