using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static List<long>[] to;
		static bool[] done; 
		static long ans = 1;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long k = cin.Long();

			ModCounting.Initialize(k, MOD);

			to = new List<long>[n + 1];
			for (int i = 0; i < n + 1; i++) {
				to[i] = new List<long>();
			}
			done = new bool[n];
			for (int i = 0; i < n - 1; i++) {
				long a = cin.Long();
				long b = cin.Long();
				to[a].Add(b);
				to[b].Add(a);
			}

			DFS(-1, 1, k);

			Console.WriteLine(ans);
		}

		static void DFS(long parent, long num, long k)
		{
			long cnt = 0;
			foreach (long t in to[num]) {
				if (t == parent) {
					continue;
				}

				DFS(num, t, k);
				++cnt;
			}

			long kk = parent == -1 ? k : k - 2;
			if (parent == -1) {
				cnt += 1;
			}

			long p = ModCounting.Permutation(kk, cnt);
			ans = (ans * p) % MOD;
		}
	}

	public static class ModCounting
	{
		/// <summary>
		/// 剰余演算(mod)の除数
		/// </summary>
		private static long p_;

		/// <summary>
		/// factorial_[n] は n! mod p となる
		/// </summary>
		private static long[] factorial_;
		/// <summary>
		/// inverseFactorial_[n] は (n!)^-1 mod p となる
		/// </summary>
		private static long[] inverseFactorial_;
		/// <summary>
		/// inverse_[n] は n^-1 mod p となる
		/// </summary>
		private static long[] inverse_;

		/// <summary>
		/// 必要な階乗と逆元のテーブルを作成する
		/// </summary>
		/// <param name="max">最大値</param>
		/// <param name="p">剰余演算(mod)の除数</param>
		public static void Initialize(long max, long p)
		{
			p_ = p;

			factorial_ = new long[max + 1];
			inverseFactorial_ = new long[max + 1];
			inverse_ = new long[max + 1];

			factorial_[0] = factorial_[1] = 1;
			inverseFactorial_[0] = inverseFactorial_[1] = 1;
			inverse_[1] = 1;
			for (int i = 2; i <= max; i++) {
				factorial_[i] = factorial_[i - 1] * i % p;
				inverse_[i] = p - inverse_[p % i] * (p / i) % p;
				inverseFactorial_[i] = inverseFactorial_[i - 1] * inverse_[i] % p;
			}
		}

		/// <summary>
		/// mod pにおけるnの逆元を計算 (O(1))
		/// </summary>
		/// <param name="n"></param>
		/// <returns></returns>
		public static long Inverse(long n)
		{
			if (n < 0) {
				return 0;
			}

			return inverse_[n];
		}

		/// <summary>
		/// 順列nPk mod pを計算 (O(1))
		/// </summary>
		/// <param name="n">ものの数</param>
		/// <param name="k">選ぶ数</param>
		/// <returns>nPk mod p</returns>
		public static long Permutation(long n, long k)
		{
			if (n < k || (n < 0 || k < 0)) {
				return 0;
			}

			// n! / (n - k)! mod p
			return factorial_[n] * inverseFactorial_[n - k] % p_;
		}

		/// <summary>
		/// 組み合わせnCk mod pを計算 (O(1))
		/// </summary>
		/// <param name="n">ものの数</param>
		/// <param name="k">選ぶ数</param>
		/// <returns>nCk mod p</returns>
		public static long Combination(long n, long k)
		{
			if (n < k || (n < 0 || k < 0)) {
				return 0;
			}

			// n! / (k! * (n - k)!) mod p
			return factorial_[n] * (inverseFactorial_[k] * inverseFactorial_[n - k] % p_) % p_;
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 42380