h,w = map(int,input().split()) mod = 10**9+7 fact = [1,1] finv = [1,1] inv = [0,1] for i in range(2,h+5): fact.append((fact[-1]*i)%mod) inv.append((inv[mod%i]*(mod-mod//i))%mod) finv.append((finv[-1]*inv[-1])%mod) def nCr(n,r,mod): if r > n: return 0 else: return fact[n]*finv[r]%mod*finv[n-r]%mod ans = 0 flag = 1 for i in range(h): l = h-i w2 = pow(2,l,mod)-1 p = pow(w2,w,mod) ans += flag * nCr(h,i,mod) * p %mod ans %= mod flag *= -1 print(ans)