use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: i64 = input();
    let ab: Vec<(usize, usize)> = (0..n - 1).map(|_| (input(), input())).collect();

    let mut e = vec![vec![]; n];
    for (a, b) in ab {
        e[a - 1].push(b - 1);
        e[b - 1].push(a - 1);
    }

    ModInt::set_mod(1000000007);
    let mut used = vec![false; n];
    println!("{}", ModInt(k) * dfs(0, &e, k, &mut used));
}

fn dfs(cur: usize, e: &Vec<Vec<usize>>, k: i64, used: &mut Vec<bool>) -> ModInt {
    used[cur] = true;
    let p = if cur == 0 { 0 } else { 1 };
    let mut ret = ModInt(1);
    let mut i = k - p - 1;
    for &next in &e[cur] {
        if !used[next] {
            ret *= i;
            ret *= dfs(next, e, k, used);
            i -= 1;
        }
    }
    ret
}

static mut MOD: i64 = 0;

#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct ModInt(i64);

impl ModInt {
    fn new(x: i64) -> ModInt {
        let m = ModInt::get_mod();
        ModInt(if x < m { x } else { x % m })
    }

    fn get_mod() -> i64 {
        unsafe { MOD }
    }

    fn set_mod(x: i64) {
        unsafe {
            MOD = x;
        }
    }
}

impl std::fmt::Display for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

impl std::ops::AddAssign<ModInt> for ModInt {
    fn add_assign(&mut self, other: ModInt) {
        let m = ModInt::get_mod();
        self.0 += other.0;
        if self.0 >= m {
            self.0 -= m;
        }
    }
}

impl std::ops::MulAssign<ModInt> for ModInt {
    fn mul_assign(&mut self, other: ModInt) {
        let m = ModInt::get_mod();
        self.0 *= other.0;
        if self.0 >= m {
            self.0 %= m;
        }
    }
}

impl std::ops::SubAssign<ModInt> for ModInt {
    fn sub_assign(&mut self, other: ModInt) {
        let m = ModInt::get_mod();
        self.0 += m - other.0;
        if self.0 >= m {
            self.0 -= m;
        }
    }
}

macro_rules! impl_modint_assign_op_ref {
    ($imp:ident, $method:ident) => {
        impl<'a> std::ops::$imp<&'a ModInt> for ModInt {
            fn $method(&mut self, other: &'a ModInt) {
                std::ops::$imp::$method(self, *other);
            }
        }
    };
}

impl_modint_assign_op_ref!(AddAssign, add_assign);
impl_modint_assign_op_ref!(MulAssign, mul_assign);
impl_modint_assign_op_ref!(SubAssign, sub_assign);

macro_rules! impl_modint_op {
    ($imp:ident, $method:ident, $assign_t:ident, $assign_m:ident) => {
        impl std::ops::$imp<ModInt> for ModInt {
            type Output = ModInt;

            fn $method(self, other: ModInt) -> ModInt {
                let mut x = self;
                std::ops::$assign_t::$assign_m(&mut x, other);
                x
            }
        }
    };
}

impl_modint_op!(Add, add, AddAssign, add_assign);
impl_modint_op!(Mul, mul, MulAssign, mul_assign);
impl_modint_op!(Sub, sub, SubAssign, sub_assign);

macro_rules! impl_modint_op_ref {
    ($imp:ident, $method:ident) => {
        impl<'a> std::ops::$imp<ModInt> for &'a ModInt {
            type Output = ModInt;

            fn $method(self, other: ModInt) -> ModInt {
                std::ops::$imp::$method(*self, other)
            }
        }

        impl<'a> std::ops::$imp<&'a ModInt> for ModInt {
            type Output = ModInt;

            fn $method(self, other: &'a ModInt) -> ModInt {
                std::ops::$imp::$method(self, *other)
            }
        }

        impl<'a, 'b> std::ops::$imp<&'b ModInt> for &'a ModInt {
            type Output = ModInt;

            fn $method(self, other: &'b ModInt) -> ModInt {
                std::ops::$imp::$method(*self, *other)
            }
        }
    };
}

impl_modint_op_ref!(Add, add);
impl_modint_op_ref!(Mul, mul);
impl_modint_op_ref!(Sub, sub);

macro_rules! impl_modint_op_i64 {
    ($imp:ident, $method:ident) => {
        impl<T: Into<i64>> std::ops::$imp<T> for ModInt {
            type Output = ModInt;

            fn $method(self, other: T) -> ModInt {
                std::ops::$imp::$method(self, ModInt::new(other.into()))
            }
        }
    };
}

impl_modint_op_i64!(Add, add);
impl_modint_op_i64!(Mul, mul);
impl_modint_op_i64!(Sub, sub);

macro_rules! impl_modint_assign_op_i64 {
    ($imp:ident, $method:ident) => {
        impl<T: Into<i64>> std::ops::$imp<T> for ModInt {
            fn $method(&mut self, other: T) {
                std::ops::$imp::$method(self, ModInt::new(other.into()));
            }
        }
    };
}

impl_modint_assign_op_i64!(AddAssign, add_assign);
impl_modint_assign_op_i64!(MulAssign, mul_assign);
impl_modint_assign_op_i64!(SubAssign, sub_assign);

macro_rules! impl_modint_accum {
    ($imp:ident, $method:ident, $id:expr, $op_t:ident, $op_m:ident) => {
        impl std::iter::$imp for ModInt {
            fn $method<I: Iterator<Item = ModInt>>(iter: I) -> ModInt {
                iter.fold(ModInt($id), std::ops::$op_t::$op_m)
            }
        }

        impl<'a> std::iter::$imp<&'a ModInt> for ModInt {
            fn $method<I: Iterator<Item = &'a ModInt>>(iter: I) -> ModInt {
                iter.fold(ModInt($id), std::ops::$op_t::$op_m)
            }
        }
    };
}

impl_modint_accum!(Sum, sum, 0, Add, add);
impl_modint_accum!(Product, product, 1, Mul, mul);


Measured memory_bytes: 17148