program cojs630;
const
p=10007;
var
a,b,i,j,m,n,k,q,x,y,ans:longint;
begin
assign(input,'factor.in');
assign(output,'factor.out');
reset(input);
rewrite(output);
ans:=1;
readln(a,b,k,n,m);
a:=a mod p;
b:=b mod p;
for i:=1 to n do
ans:=ans*a mod p;
for j:=1 to m do
ans:=ans*b mod p;
for i:=1 to k do
ans:=ans*i mod p;
x:=1;
for i:=1 to n do
x:=x*i mod p;
for i:=1 to m do
x:=x*i mod p;
y:=p-2;
q:=1;
while y>0 do
begin
if y and 1=1 then q:=q*x mod p;
x:=x*x mod p;
y:=y shr 1;
end;
ans:=ans*q mod p;
writeln(ans);
close(input);
close(output);
end.