description: A tree is an undirected connected graph without cycles.
  
  You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exists an integer c such that for all u, v (u ≠ v, u, v are in selected vertices) d_{u,v}=c, where d_{u,v} is the distance from u to v).
  
  Since the answer may be very large, you need to output it modulo 10^9 + 7.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.
  
  Each test case is preceded by an empty line.
  
  Each test case consists of several lines. The first line of the test case contains two integers n and k (2 ≤ k ≤ n ≤ 100) — the number of vertices in the tree and the number of vertices to be selected, respectively. Then n - 1 lines follow, each of them contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) which describe a pair of vertices connected by an edge. It is guaranteed that the given graph is a tree and has no loops or multiple edges.
  
  Output
  
  For each test case output in a separate line a single integer — the number of ways to select exactly k vertices so that for all pairs of selected vertices the distances between the vertices in the pairs are equal, modulo 10^9 + 7 (in other words, print the remainder when divided by 1000000007).
  
  Example
  
  Input
  
  
  3
  
  4 2
  1 2
  2 3
  2 4
  
  3 3
  1 2
  2 3
  
  5 3
  1 2
  2 3
  2 4
  4 5
  
  
  Output
  
  
  6
  0
  1
solution: #include <bits/stdc++.h>
  using namespace std;
  long long TC;
  long long N, K, a, b;
  vector<long long> adj[101], B[101];
  long long twok[101][10];
  void dfs(long long x, long long p, long long d) {
    B[d].push_back(x);
    twok[x][0] = p;
    for (long long i = 1; i <= long long(9); ++i) {
      if (twok[x][i - 1] == -1) break;
      twok[x][i] = twok[twok[x][i - 1]][i - 1];
    }
    for (auto i : adj[x])
      if (i != p) dfs(i, x, d + 1);
  }
  long long kpar(long long x, long long k) {
    for (long long i = 0; i <= long long(9); ++i)
      if (k & (1 << i)) x = twok[x][i];
    return x;
  }
  long long C[101];
  long long qexp(long long x, long long y) {
    long long res = 1;
    while (y > 0) {
      if (y & 1) (res *= x) %= 1000000007;
      y >>= 1;
      (x *= x) %= 1000000007;
    }
    return res;
  }
  long long dp[101][101];
  long long getnum(vector<long long> &v, long long k) {
    if (k > v.size()) return 0;
    for (long long i = 0; i <= long long(v.size() - 1); ++i)
      for (long long j = 0; j <= long long(k); ++j) {
        if (j == 0)
          dp[i][j] = 1;
        else if (i + 1 < j)
          dp[i][j] = 0;
        else if (i == 0)
          dp[i][j] = v[i];
        else
          dp[i][j] = (((v[i] * dp[i - 1][j - 1]) % 1000000007) + dp[i - 1][j]) %
                     1000000007;
      }
    return dp[v.size() - 1][k];
  }
  void solve() {
    cin >> N >> K;
    for (long long i = 1; i <= long long(N); ++i) adj[i].clear();
    for (long long i = 1; i <= long long(N - 1); ++i) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    if (K == 2) {
      cout << (N * (N - 1)) / 2 << '\n';
      return;
    }
    long long ans = 0;
    for (long long i = 1; i <= long long(N); ++i) {
      for (long long j = 0; j <= long long(N - 1); ++j) B[j].clear();
      memset(twok, -1, sizeof twok);
      dfs(i, -1, 0);
      for (long long c = 2; c < N; c += 2) {
        if (B[c].size() < K - 1) continue;
        for (auto j : B[c]) {
          C[kpar(j, c / 2 - 1)]++;
        }
        for (auto j : B[c / 2]) {
          vector<long long> v;
          for (auto k : adj[j])
            if (k != twok[j][0])
              if (C[k] > 0) v.push_back(C[k]);
          ans += getnum(v, K - 1);
          ans %= 1000000007;
        }
        for (auto j : B[c]) {
          C[kpar(j, c / 2 - 1)] = 0;
        }
      }
    }
    cout << (ans * qexp(K, 1000000007 - 2)) % 1000000007 << '\n';
  }
  int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> TC;
    for (long long i = 1; i <= long long(TC); ++i) solve();
  }
  