#include #include using ll = long long; struct mint{ static constexpr int m = 1000000007; int x; mint() : x(0){} mint(ll x_):x(x_%m){if(x<0)x+=m;} int val(){return x;} mint &operator+=(mint b){if((x+=b.x)>=m)x-=m; return *this;} mint &operator-=(mint b){if((x-=b.x)<0)x+=m; return *this;} mint &operator*=(mint b){x=ll(x)*b.x%m; return *this;} mint pow(ll e) const { mint r = 1,b =*this; while(e){ if(e&1) r*=b; b*=b; e>>=1; } return r; } mint inv(){return pow(m-2);} mint &operator/=(mint b){return *this*=b.pow(m-2);} friend mint operator+(mint a,mint b){return a+=b;} friend mint operator-(mint a,mint b){return a-=b;} friend mint operator/(mint a,mint b){return a/=b;} friend mint operator*(mint a,mint b){return a*=b;} friend bool operator==(mint a,mint b){return a.x==b.x;} friend bool operator!=(mint a,mint b){return a.x!=b.x;} }; namespace po167{ template struct Binomial{ std::vector fact_vec, fact_inv_vec; void extend(int m = -1){ int n = fact_vec.size(); if (m == -1) m = n * 2; if (n >= m) return; fact_vec.resize(m); fact_inv_vec.resize(m); for (int i = n; i < m; i++){ fact_vec[i] = fact_vec[i - 1] * T(i); } fact_inv_vec[m - 1] = T(1) / fact_vec[m - 1]; for (int i = m - 1; i > n; i--){ fact_inv_vec[i - 1] = fact_inv_vec[i] * T(i); } } Binomial(int MAX = 2){ fact_vec.resize(1, T(1)); fact_inv_vec.resize(1, T(1)); extend(MAX + 1); } T fact(int i){ if (i < 0) return 0; while (int(fact_vec.size()) <= i) extend(); return fact_vec[i]; } T invfact(int i){ if (i < 0) return 0; while (int(fact_inv_vec.size()) <= i) extend(); return fact_inv_vec[i]; } T C(int a, int b){ if (a < b || b < 0) return 0; return fact(a) * invfact(b) * invfact(a -b); } T P(int a, int b){ if (a < b || b < 0) return 0; return fact(a) * invfact(a - b); } T inv(int a){ if (a < 0) return inv(-a) * T(-1); if (a == 0) return 1; return fact(a - 1) * invfact(a); } }; } int main(){ int h,w; std::cin >> h >> w; po167::Binomial table(h + w); mint ans = 0; for(int i = 0; i <= h; i++){ ans += mint(-1).pow(i) * table.C(h, i) * (mint(2).pow(h - i) - 1).pow(w); } std::cout << ans.val() << "\n"; }