class Solution(object):
def superPow(self, a, b):
"""
:type a: int
:type b: List[int]
:rtype: int
"""
mod = 1337
ans = 1
for e in reversed(b):
ans = ans * pow(a, e, mod) % mod
a = pow(a, 10, mod)
return ans