import sys #input = sys.stdin.readline #文字列につけてはダメ #input = sys.stdin.buffer.readline #文字列につけてはダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) ret = fac[n] * finv[r] % p ret = ret * finv[n-r] % p return ret def cmb_inv(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) ret = fac[n-r] * fac[r] % p ret = ret * finv[n] % p return ret def perm(n,r,p): if (r < 0) or (n < r): return 0 return fac[n]*finv[n-r]%p n = 2*pow(10,6) + 100 fac = [-1]*(n+1); fac[0] = 1; fac[1] = 1 #階乗 finv = [-1]*(n+1); finv[0] = 1; finv[1] = 1 #階乗の逆元 inv = [-1]*(n+1); inv[0] = 0; inv[1] = 1 #逆元 for i in range(2,n+1): fac[i] = fac[i-1]*i%MOD inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD finv[i] = finv[i-1]*inv[i]%MOD pow2 = [1] mx = 2*pow(10,6) + 100 for i in range(mx): temp = pow2[-1]*2%MOD pow2.append(temp) def sgn(x): if x%2 == 0: return 1 else: return - 1 def main(): H,W = map(int,input().split()) ans = 0 for i in range(H+1): #i行が0のみ x = pow2[H-i] - 1 #列に一つでも1がある決め方。"全通り - 0のみの1通り" temp = cmb(H,i,MOD) * sgn(i) * pow(x,W,MOD) %MOD ans += temp ans %= MOD print(ans) if __name__ == '__main__': main()