using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{

        static long[] fac = new long[100001];
        static long[] ifac = new long[100001];
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            fac[0] = 1;
            ifac[0] = 1;
            for(long i=0;i<100000;i++){
                fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*Mpow(i+1, MOD-2) % MOD;
            }
            long[] nk = ILongs();
            long[][] ab = ILongLongs(nk[0]-1);

            List<long>[] tonari = new List<long>[nk[0]];
            for(int i=0;i<nk[0];i++){
                tonari[i] = new List<long>();
            }

            bool[] moumita = new bool[nk[0]];

            for(int i=0;i<nk[0]-1;i++){
                tonari[ab[i][0]-1].Add(ab[i][1]-1);
                tonari[ab[i][1]-1].Add(ab[i][0]-1);
            }

            long ans = nk[1];

            Queue<long> q = new Queue<long>();
            q.Enqueue(0);

            if(nk[0]==1){
                Console.WriteLine(nk[1]);
                return;
            }

            while(q.Count>0){
                long ima = q.Dequeue();
                moumita[ima] = true;

                if(tonari[ima].Count-1>nk[1]-2){
                    Console.WriteLine(0);
                    return;
                }
                if(ima==0){
                        ans *= Perm(nk[1]-1,tonari[ima].Count);
                ans %= MOD;
                }else if(tonari[ima].Count!=1){
                    
ans *= Perm(nk[1]-2,tonari[ima].Count-1);
                ans %= MOD;
                }

                foreach(long tnr in tonari[ima]){
                    if(!moumita[tnr]){
                        q.Enqueue(tnr);
                    }
                }
            }

            Console.WriteLine(ans);
        }

        static long Comb(long a,long b){
            if(a==0&&b==0)return 1;
            if(a<b||a<0)return 0;
            long tmp = ifac[a-b]*ifac[b]%MOD;
            return tmp * fac[a]%MOD;
        }

        static long Mpow(long x,long n){
            long ans = 1;
            while(n!=0){
                if(n%2==1)ans = ans *x%MOD;
                x = x*x % MOD; 
                n = n /2;
            }
            return ans;
        }

        static long Perm(long a, long b){
            if(a<b)return 0;
            long tmp = ifac[a-b]%MOD;
            return tmp * fac[a] % MOD;
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 38956