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