#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MOD = (int)1e9 + 7;
int Pow(int x, int y) {
int r = 1;
for (; y; y >>= 1, x = (LL)x * x % MOD)
if (y & 1) r = (LL)r * x % MOD;
return r;
}
int main() {
freopen("game.in", "r", stdin);
freopen("game.out", "w", stdout);
int n, m, ans = 0;
scanf("%d%d", &n, &m);
if (n > m) swap(n, m);
if (n == 1) {
ans = Pow(2, m);
}
else if (n == 2) {
ans = 4LL * Pow(3, m - 1) % MOD;
}
else if (n == 3) {
ans = 112LL * Pow(3, m - 3) % MOD;
}
ans = (ans + MOD) % MOD;
printf("%d\n", ans);
return 0;
}