import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1].to!long;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    long dfs(int n, int p) {
        long tmp = 1;
        long k = p == -1 ? K - 1 : K - 2;
        foreach (m; G[n]) if (m != p) tmp = tmp * (k--) % MOD * dfs(m, n) % MOD;
        return tmp;
    }

    long ans = dfs(0, -1) * K % MOD;
    ans.writeln;
}