#include #include #include using namespace std; const int mod = 1e9 + 7; struct ModInt { int n,mod; vector f; vector invf; ModInt(int n,int mod):n(n),mod(mod){ f.resize(n+1); invf.resize(n+1); preWork(n); } void preWork(int n){ f[0] = 1; for(int i = 1; i <= n; i++) f[i] = f[i-1]*1ll*i%mod; invf[n] = power(f[n],mod-2); for(int i = n-1; i >= 0; i--) invf[i] = invf[i+1]*1ll*(i+1)%mod; } int power(int a,int b){ int res = 1; while(b){ if(b&1) res = res*1ll*a%mod; a = a*1ll*a%mod; b /= 2; } return res; } int comb(int n,int m){ return f[n]*1ll*invf[m]%mod*invf[n-m]%mod; } }; auto md = ModInt(1000000, mod); int main() { int n, m; scanf("%d%d", &n, &m); int ans = 0; for (int i = 0; i <= m; i++) { int x = md.comb(m, i); int y = md.power(2, m - i) - 1; if (y < 0) y += mod; int way = x * 1ll * md.power(y, n) % mod; if (i % 2) way = way * 1ll * (mod - 1) % mod; ans += way; // printf("i = %d: %d\n", i, way); if (ans >= mod) ans -= mod; } printf("%d\n", ans); return 0; }