#include #include using namespace std; typedef long long ll; typedef vector vl; typedef vector vvl; const ll mod=1e9+7; ll Pow_mod(ll n,ll p){ ll r=1; for(;p>0;p>>=1){ if(p&1) r=(r*n)%mod; n=(n*n)%mod; } return r; } vl fact(1000000); ll Fact(ll n){ if(fact[n]) return fact[n]; if(!n) return fact[n]=1; return fact[n]=Fact(n-1)*n%mod; } ll Division_mod(ll n,ll m){ return n*Pow_mod(m,mod-2)%mod; } ll Combination(ll n,ll k){ return Division_mod(Fact(n),Fact(n-k)*Fact(k)%mod); } ll N,K,D; int main(){ cin>>N>>K>>D; ll num=(N-1)/(K-1),len=N-num*(K-1); if(D==1){ cout<