#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int f[1500][1500]={0};
long long ksm(long long a,long long b,long long n)//a的b次方,n
{
long long ans=1,base=a;
while(b!=0)
{
if(b&1!=0)
ans=ans*base%n;
base=base*base%n;
b>>=1;
}
return ans;
}
int yh(int k)
{
f[1][0]=f[1][1]=1;
for (int i=2;i<=k;i++)
{
f[i][0]=1;
for (int j=1;j<=i;j++)
f[i][j]=(f[i-1][j-1]+f[i-1][j])%10007;
}
}
int main()
{
freopen("factor.in","r",stdin);
freopen("factor.out","w",stdout);
long long a=0,b=0,k=0,n=0,m=0;
cin>>a>>b>>k>>n>>m;
a=ksm(a,n,10007);
b=ksm(b,m,10007);
yh(k);
int j=10007;
int ans=1;
long long anss=((a*b)%j*f[k][m])%j;
cout<<anss;
}