```
class Solution {
public:
int superPow(int a, vector<int>& b) {
long previous = 1;
long base = a;
for (int i = b.size() - 1; i >= 0; --i) {
for (int j = 0; j < b[i]; ++j) {
previous *= base;
previous = previous % 1337;
}
long temp_base = base;
for (int i = 1; i < 10; ++i) {
base *= temp_base;
base = base % 1337;
}
}
return previous;
}
};
```