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;
  using ll = long long;
  using pii = pair<int, int>;
  using pll = pair<ll, ll>;
  using vi = vector<int>;
  using vl = vector<ll>;
  using vii = vector<pii>;
  using vll = vector<pll>;
  ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
  ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
  vector<int> sieve;
  void calc_sieve(int n) {
    sieve.reserve(n + 1);
    for (int i = 0, nnnn = (n + 1); i < nnnn; ++i) sieve[i] = i;
    for (int i = 2, nnnn = (n + 1); i < nnnn; ++i) {
      if (sieve[i] == i) {
        for (ll j = i * i; j <= n; j += i) {
          if (sieve[j] == j) sieve[j] = i;
        }
      }
    }
  }
  ll norm(ll a, ll P) {
    while (a >= P) a -= P;
    while (a < 0) a += P;
    return a;
  }
  ll mul_mod(ll a, ll b, ll P) { return a * b % P; }
  ll pow_mod(ll a, ll b, ll P) {
    ll curr = a, ans = 1;
    while (b != 0) {
      if (b & 1) {
        ans *= curr;
        ans %= P;
      }
      curr *= curr;
      curr %= P;
      b >>= 1;
    }
    return ans;
  }
  ll inv_mod(ll a, ll P) { return pow_mod(a, P - 2ll, P); }
  ll div_mod(ll a, ll b, ll P) { return a * inv_mod(b, P) % P; }
  int msb(ll a) {
    for (int i = 62; i >= 0; i--) {
      if (a & ((ll)1 << i)) return i + 1;
    }
    return 0;
  }
  vector<ll> fact;
  void calc_fact(int n, ll P) {
    if (fact.size() < 1) fact.push_back(1);
    for (int i = fact.size(), nnnn = (n + 1); i < nnnn; ++i)
      fact.push_back(fact[i - 1] * i % P);
  }
  vector<ll> fact_inv;
  void calc_fact_inv(int n, ll P) {
    if (fact_inv.size() < 1) fact_inv.push_back(1);
    for (int i = fact_inv.size(), nnnn = (n + 1); i < nnnn; ++i)
      fact_inv.push_back(fact_inv[i - 1] * inv_mod(i, P) % P);
  }
  ll nCr(int n, int r, ll P) {
    if (r > n) return 0;
    calc_fact(n, P);
    calc_fact_inv(n, P);
    return (fact[n] * fact_inv[r] % P) * fact_inv[n - r] % P;
  }
  ll nCr_inv(int n, int r, ll P) {
    if (r > n) return 0;
    calc_fact(n, P);
    calc_fact_inv(n, P);
    return (fact_inv[n] * fact[r] % P) * fact[n - r] % P;
  }
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  const long double eps = 1e-9;
  const long long mod = 1000000007;
  const int MAXN = 100;
  vector<int> adjlist[MAXN];
  vector<vector<int>> v;
  int n, k;
  ll f[MAXN], invf[MAXN];
  void dfs(int curr, int dist, int p, vector<int> &v) {
    v[dist]++;
    for (int i : adjlist[curr]) {
      if (i != p) {
        dfs(i, dist + 1, curr, v);
      }
    }
  }
  void solve() {
    cin >> n >> k;
    for (int i = 0, nnnn = (n); i < nnnn; ++i) adjlist[i].clear();
    for (int i = 0, nnnn = (n - 1); i < nnnn; ++i) {
      int a, b;
      cin >> a >> b;
      adjlist[a - 1].push_back(b - 1);
      adjlist[b - 1].push_back(a - 1);
    }
    if (k == 2) {
      cout << (n - 1) * n / 2 << endl;
    } else {
      ll ans = 0;
      for (int i = 0, nnnn = (n); i < nnnn; ++i) {
        v = vector<vector<int>>(adjlist[i].size(), vector<int>(n, 0));
        for (int j = 0, nnnn = (adjlist[i].size()); j < nnnn; ++j) {
          dfs(adjlist[i][j], 0, i, v[j]);
        }
        for (int j = 0, nnnn = (n); j < nnnn; ++j) {
          ll dp[k];
          memset(dp, 0, sizeof dp);
          for (int l = 0, nnnn = (adjlist[i].size()); l < nnnn; ++l) {
            for (int m = k - 1; m >= 1; m--)
              dp[m] += dp[m - 1] * v[l][j], dp[m] %= mod;
            dp[0] += v[l][j];
          }
          ans += dp[k - 1];
        }
      }
      cout << ans % mod << endl;
    }
  }
  int main() {
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1, nnnn = (MAXN); i < nnnn; ++i)
      f[i] = f[i - 1] * i % mod, invf[i] = invf[i - 1] * inv_mod(i, mod) % mod;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(12) << fixed;
    int t;
    cin >> t;
    while (t--) solve();
  }
  