#include /*#include #include */#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*namespace mp = boost::multiprecision; using Bint = mp::cpp_int; using Real = mp::number>; */#define lli long long int #define uli unsigned long long int #define INF 999999999999 #define rep(i,m,n) for(lli i = m;i < n;i++) #define rrep(i,m,n) for(lli i=m-1;i>=n;i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(),N.end()),N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(),n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(50) << S << endl #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,S) vector> K(N,vector(M,S)) #define TV(K,L,N,M,R,S) vector>> K(N,vector>(M,vector(R,S))) #define pint pair #define paf(L,R) pair #define mod 1000000007 #define MAX 10000000 #define ALL(a) a.begin(),a.end() #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) long long N,K,sum=0,num=0; lli modpow(lli n,lli k,lli m){ if(k==0)return 1; else if(k%2==1)return modpow(n,k-1,m)*n%m; else{ lli temp=modpow(n,k/2,m); return temp*temp%m; } } void dfs(int n,vector&P){ if(n)rep(i,0,K){ P[n-1]=i+1; dfs(n-1,P); } else{ rep(p,0,(1<> N >> K; /* Vec(P,int,N,0); dfs(N,P); Out(sum); */ Out((modpow(K*(K+3)%mod*modpow(2,mod-2,mod)%mod,N,mod)-modpow(K*(K+1)%mod*modpow(2,mod-2,mod)%mod,N,mod)+10LL*mod)%mod); }