mod = 10 ** 9 + 7 div2 = pow(2, mod - 2, mod) class Combination: """ SIZEが10**6程度以下の二項係数を何回も呼び出したいときに使う 使い方: comb = Combination(SIZE, MOD) comb(10, 3) => 120 """ def __init__(self, N, MOD=10 ** 9 + 7): self.MOD = MOD self.__make_factorial_list(N) def __call__(self, n, k): if k < 0 or k > n: return 0 res = self.fact[n] * self.inv[k] % self.MOD res = res * self.inv[n - k] % self.MOD return res def nPk(self, n, k): if k < 0 or k > n: return 0 return self.fact[n] * self.inv[n - k] % self.MOD def nHk(self, n, k): if k == 0: return 1 return self.__call__(n + k - 1, k) def __make_factorial_list(self, N): self.fact = [1] * (N + 1) self.inv = [1] * (N + 1) MOD = self.MOD for i in range(1, N + 1): self.fact[i] = (self.fact[i - 1] * i) % MOD self.inv[N] = pow(self.fact[N], MOD - 2, MOD) for i in range(N, 0, -1): self.inv[i - 1] = (self.inv[i] * i) % MOD return def main(): H, W = map(int, input().split()) comb = Combination(10 ** 6 + 5, mod) ans = 0 a = pow(2, H * W, mod) diva = pow(div2, W, mod) r = mod-pow(div2, H, mod) divr = 2 for i in range(H + 1): ai = a if i % 2 == 1: ai = mod - ai n = W + 1 tot = ai * pow(1 + r, W, mod) tot = tot * comb(H, i) % mod ans = (ans + tot) % mod a = a * diva % mod r = r * divr % mod return ans print(main())