1
2
#include<bits/stdc++.h>
using namespace std;using ll=long long;const int P=1000000007;ll q(ll a,ll e){ll r=1;while(e){if(e&1)r=r*a%P;a=a*a%P;e>>=1;}return r;}int main(){ios::sync_with_stdio(0);cin.tie(0);int n,k,m;cin>>n>>k>>m;vector<int>v(k+1);v[1]=1;for(int i=2;i<=k;++i)v[i]=P-(ll)(P/i)*v[P%i]%P;int u=v[k];vector<int>a(m);a[0]=1;ll w=1;int l=max(0,m-k);ll e=l>0?1:0;for(int x=1;x<m;++x){a[x]=(ll)w*u%P;w+=a[x];if(w>=P)w-=P;if(x>=k){w-=a[x-k];if(w<0)w+=P;}if(x<l){e+=a[x];if(e>=P)e-=P;}}ll r=(ll)(n%P)*e%P;vector<int>s(m+1);for(int x=m-1;x>=l;--x){int c=x+k-m+1;ll b=(ll)a[x]*c%P*u%P;s[x]=s[x+1]+(int)b;if(s[x]>=P)s[x]-=P;}ll p=0;for(int x=m-1;x>=l;--x){ll y=q(s[x],n);ll d=y-p;if(d<0)d+=P;int c=x+k-m+1;r+=(ll)k*v[c]%P*d%P;if(r>=P)r-=P;p=y;}cout<<r%P<<'\n';}