program permutation;
var
f:array[0..100,0..100]of longint;
i,j,k,l:longint;
n,m:longint;
begin
assign(input,'permutation.in');
reset(input);
assign(output,'permutation.out');
rewrite(output);
for i:=0 to 100 do
for j:=0 to 100 do
f[i,j]:=0;
n:=100;
m:=100;
for i:=1 to n do
f[0,i]:=1;
f[1,2]:=1;
for j:=3 to n do
f[1,j]:=(f[1,j-1]*2+f[0,j-1]*(j-1))mod 2007;
for i:=2 to m do
for j:=i+1 to n do
f[i,j]:=(f[i,j-1]*(i+1)+f[i-1,j-1]*(j-i))mod 2007;
while not eof do
begin
readln(n,m);
writeln(f[m,n]);
end;
close(input);
close(output);
end.