#include<cstdio>
#define M 10007
int ka[1100][1100]={0};
int sum;
int a,b,k,n,m;
long long ksm(int y,int k)
{
long long ans=1;
while (k>0)
{
if (k%2) ans=ans*y%M;
y=y*y%M;
k/=2;
}
return ans;
}
int main()
{
scanf("%d%d%d%d%d",&a,&b,&k,&n,&m);
a%=M;
b%=M;
ka[1][0]=ka[1][1]=1;
for (int i=1;i<=k;i++)
ka[i][0]=1;
for (int i=2;i<=k;i++)
for (int j=1;j<=i;j++)
ka[i][j]=(ka[i-1][j-1]+ka[i-1][j])%M;
if (a==1&&b==1)
printf("%d",ka[k][m]);
else
{
sum=(ksm(a,n)*ksm(b,m))%M*ka[k][m]%M;
printf("%d",sum);
}
return 0;
}