```
class Solution(object):
def superPow(self, a, b):
#find the cycle
cycle = self.find_cycle(a)
cycle_length = len(cycle)
#division to find the remainder
r = 0
for i in b:
r = (r * 10 + i) % cycle_length
return cycle[r - 1]
def find_cycle(self, a):
r = a % 1337
cycle = []
while r not in cycle:
cycle.append(r)
r = r * a % 1337
return cycle
```