#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL f[1010][1010],n,a,b,c,d,C[1010][1010],inv[1010][1010],fac[1010],finv[1010];
void pre()
{
	inv[0][1]=inv[1][1]=1;fac[0]=fac[1]=1;
	for(LL i=2;i<=1000;i++) inv[i][1]=(mod-mod/i)*inv[mod%i][1]%mod,fac[i]=fac[i-1]*i%mod;
	for(LL i=2;i<=1000;i++) inv[i][1]=inv[i-1][1]*inv[i][1]%mod;
	for(LL i=1;i<=1000;i++)
		for(LL j=2;j<=1000;j++) inv[i][j]=inv[i][1]*inv[i][j-1]%mod;
	for(LL i=1;i<=1000;i++)
		for(LL j=1;j<=i;j++) C[i][j]=fac[i]*inv[i-j][1]%mod;
}
LL get(LL x,LL y,LL i) {return C[x][i*y]*inv[y][i]%mod*inv[i][1]%mod;}
LL dfs(LL x,LL y)
{
	if(f[x][y]!=-1) return f[x][y];
	if(x==0) return 1;
	if(y<a) return 0;
	f[x][y]=0;
	for(LL i=c;i<=d;i++)
	{
		LL num=i*y;
		if(num<=x) (f[x][y]+=dfs(x-num,y-1)*get(x,y,i)%mod)%=mod;
		else break;
	}
	(f[x][y]+=dfs(x,y-1))%=mod;
	return f[x][y];
}
int main()
{
	pre();
	scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
	memset(f,-1,sizeof(f));
	printf("%lld",dfs(n,b));
}
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const ll MOD=998244353;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
int N,M,K;
const int MAXN=2e5+10;
ll factor[MAXN];
void init()
{
    factor[0]=1;
    for(int u=1;u<MAXN;u++){
        factor[u]=(factor[u-1]*u)%MOD;
    }
}
ll C(ll n,ll k)
{
    return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;
}
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M>>K;
    init();
    ll ans=0;
    for(int u=0;u<=K;u++){
        ans=(ans+M*C(N-1,u)%MOD*qpow(M-1,N-1-u)%MOD)%MOD;
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}