#include using namespace std; typedef long long LL; #define CIN_ONLY if(1) struct cww{cww(){ CIN_ONLY{ ios::sync_with_stdio(false);cin.tie(0); } }}star; #define fin "\n" #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define fi first #define se second #define pb push_back #define DEBUG if(0) #define REC(ret, ...) std::function template inline bool chmin(T &l,T r) {bool a=l>r;if(a)l=r;return a;} template inline bool chmax(T &l,T r) {bool a=l istream& operator>>(istream &is,vector &v){ for(auto &it:v)is>>it; return is; } const int mod=1e9+7; // a x + b y = gcd(a, b) // O(log (a+b) ) LL extgcd(LL a, LL b, LL &x, LL &y) { LL g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // 階乗 // O(n) #define SZ 3000010 LL fact[SZ]; struct fact_{ fact_(){ fact[0]=1; for(int i=1;i>N>>K>>D; LL d=(N-1)/(K-1); LL M=N-d*(K-1); LL res=0; LL dd=1; REP(i,d+1){ res+=(dd*M%mod)*H(M-1,d-i)%mod; res%=mod; dd=dd*D%mod; } if(D==1) cout<