import sys from operator import itemgetter from collections import defaultdict, deque import heapq import bisect import math import itertools import copy stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = 1 << 60 inf = float('inf') mod = 10 ** 9 + 7 #mod = 998244353 eps = 1e-9 sortkey1 = itemgetter(0) sortkey2 = lambda x: (x[0], x[1]) class Comb(): def __init__(self, N, mod): self.N = N self.mod = mod self.fa = self.fa_fainv()[0] self.fainv = self.fa_fainv()[1] def fa_fainv(self): fa = [1] for i in range(1, self.N + 1): fa.append(fa[-1] * i % self.mod) fainv = [pow(fa[-1],self.mod - 2,self.mod)] for i in range(1, self.N + 1)[::-1]: fainv.append(fainv[-1] * i % self.mod) fainv = fainv[::-1] return fa, fainv def aCb(self, a, b): if b < 0 or a < b: return 0 return self.fa[a] * self.fainv[a - b] * self.fainv[b] % self.mod def aPb(self, a, b): if b < 0 or a < b: return 0 return self.fa[a] * self.fainv[a - b] ############################################################### H, W = lp() comb = Comb(10 ** 6 + 2, mod) ans = 0 s = -1 for i in range(H + 1): s *= -1 p = pow(2, H - i, mod) p = pow(p, mod - 2, mod) C = comb.aCb(H, i) * pow(2, H * W - W * i, mod) r = pow(1 - p, W, mod) q = s * C * r ans += q ans %= mod print(ans)