289_D. Polo the Penguin and Houses _6392
Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).

Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number x. Then he goes to the house whose number is written on the plaque of house x (that is, to house px), then he goes to the house whose number is written on the plaque of house px (that is, to house ppx), and so on.

We know that:

  1. When the penguin starts walking from any house indexed from 1 to k, inclusive, he can walk to house number 1. 
  2. When the penguin starts walking from any house indexed from k + 1 to n, inclusive, he definitely cannot walk to house number 1. 
  3. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house. 



You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by 1000000007 (109 + 7).

Input

The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ min(8, n)) — the number of the houses and the number k from the statement.

Output

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

5 2


Output

54


Input

7 4


Output

1728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    static int i, j, k, n, m, t, y, x, sum;
    static long mod = 1000000007;
    static FastScanner fs = new FastScanner();
    static PrintWriter out = new PrintWriter(System.out);
    static String str;
    static int[] arr = new int[10];

    static long ans=0;

    public static void main(String[] args) {

        int n = fs.nextInt();
        k = fs.nextInt();

        combi(0);

        long m1 = ans;
        long m2 = 1;

        long temp = n-k;

        for(i=0;i<n-k;i++){
            m2*=temp;

            m2%=mod;
        }

        ans = (m1*m2)%mod;

        out.println(ans);


        out.close();
    }

    private static void combi(int a){

        if(a==k){
            if(isValid()) {
                ans++;
                ans%=mod;
            }

        }

        else{
            for(int i=0;i<k;i++){
                arr[a]=i;
                combi(a+1);
            }
        }
    }

    private static boolean isValid(){
        long[] vis = new long[k];

        initialize(vis, -1);

        vis[0]=1;

        int f =0;
        for(int i=1;i<k;i++){
            if(checkIndex(vis,i)!=1){
                f=1;
                break;
            }
        }

        return f==0;

    }

    private static int checkIndex(long[] vis,int i){
        if(vis[i]==-1){
            vis[i]=0;
            vis[i] = checkIndex(vis,arr[i]);
        }

        return (int)vis[i];
    }

    private static void initialize(long[] arr, long val){

        int n = arr.length;

        for(int i = 0;i<n;i++){
            arr[i]=val;
        }
    }



    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair implements Comparable<Pair> {
        int first, second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public int compareTo(Pair o) {
            return Long.compare(first, o.first);
        }

    }

    static void ruffleSort(int[] a) {
        //ruffle
        int n=a.length;
        Random r=new Random();
        for (int i=0; i<a.length; i++) {
            int oi=r.nextInt(n), temp=a[i];
            a[i]=a[oi];
            a[oi]=temp;
        }

        //then sort
        Arrays.sort(a);
    }


}