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;
  const long dx[4] = {1, 0, -1, 0}, dz[4] = {0, 1, 0, -1};
  const long double pi = 3.14159265359;
  const long long mod = 1e9 + 7;
  long long p(long long x) {
    while (x & (x - 1)) {
      x = x & (x - 1);
    }
    return x;
  }
  template <class T>
  void re(T& x) {
    cin >> x;
  }
  template <class T1, class T2>
  void re(pair<T1, T2>& x) {
    re(x.first);
    re(x.second);
  }
  template <class T>
  void re(vector<T>& x) {
    for (long i = 0; i < x.size(); i++) {
      re(x[i]);
    }
  }
  template <class T>
  void re(deque<T>& x) {
    for (long i = 0; i < x.size(); i++) {
      re(x[i]);
    }
  }
  template <class T>
  void out(T x) {
    cout << x << " ";
  }
  template <class T1, class T2>
  void out(pair<T1, T2> x) {
    out(x.first);
    out(x.second);
    cout << "\n";
  }
  template <class T>
  void out(vector<T> x, long l = 0, long r = 0) {
    if (!r) {
      r = x.size();
    }
    for (long i = l; i < r; i++) {
      out(x[i]);
    }
    cout << "\n";
  }
  template <class T>
  void out(deque<T> x, long l = 0, long r = 0) {
    if (!r) {
      r = x.size();
    }
    for (long i = l; i < r; i++) {
      out(x[i]);
    }
    cout << "\n";
  }
  template <class T>
  T cross(complex<T> x, complex<T> z) {
    return (conj(x) * z).imag();
  }
  template <class T>
  T dot(complex<T> x, complex<T> z) {
    return (conj(x) * z).real();
  }
  vector<vector<long long> > edges, ways;
  vector<vector<vector<long long> > > dp;
  vector<vector<vector<bool> > > ok;
  vector<long> parent, to;
  long n, k;
  void scan(long x, long p) {
    parent[x] = p;
    ways[x][0] = 1;
    for (long long i = (0); i < (edges[x].size()); i++) {
      if (edges[x][i] == p) {
        continue;
      }
      scan(edges[x][i], x);
      for (long long j = (1); j < (n + 1); j++) {
        ways[x][j] += ways[edges[x][i]][j - 1];
        ways[x][j] %= mod;
      }
    }
  }
  long long solve(long x, long c, long d) {
    if (c == 0) {
      return 1;
    }
    if (x == 0) {
      return 0;
    }
    if (ok[x][c][d]) {
      return dp[x][c][d];
    }
    ok[x][c][d] = true;
    dp[x][c][d] = solve(to[x], c, d);
    dp[x][c][d] += (ways[x][d - 1] * solve(to[x], c - 1, d));
    dp[x][c][d] %= mod;
    return dp[x][c][d];
  }
  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long t, x, z, ans, d, son;
    cin >> t;
    for (long long i = (0); i < (t); i++) {
      ans = 0;
      cin >> n >> k;
      edges.clear();
      edges.resize(n + 1);
      ways.clear();
      ways.resize(n + 1);
      for (long long j = (0); j < (n + 1); j++) {
        ways[j].resize(n + 1);
      }
      dp.clear();
      dp.resize(n + 1);
      ok.clear();
      ok.resize(n + 1);
      for (long long j = (0); j < (n + 1); j++) {
        dp[j].resize(n + 1);
        ok[j].resize(n + 1);
        for (long long l = (0); l < (n + 1); l++) {
          dp[j][l].resize(n + 1);
          ok[j][l].resize(n + 1);
        }
      }
      to.clear();
      to.resize(n + 1);
      parent.clear();
      parent.resize(n + 1);
      for (long long j = (0); j < (n - 1); j++) {
        cin >> x >> z;
        edges[x].push_back(z);
        edges[z].push_back(x);
      }
      if (k == 2) {
        cout << (n * (n - 1)) / 2 << "\n";
        continue;
      }
      scan(1, 0);
      for (long long j = (1); j < (n + 1); j++) {
        for (long long l = (1); l < (edges[j].size()); l++) {
          if (edges[j][l] == parent[j]) {
            continue;
          }
          if (edges[j][l - 1] == parent[j]) {
            if (l >= 2) {
              to[edges[j][l]] = edges[j][l - 2];
            }
            continue;
          }
          to[edges[j][l]] = edges[j][l - 1];
        }
      }
      for (long long j = (1); j < (n + 1); j++) {
        for (long long l = (1); l < (n); l++) {
          if (edges[j].back() == parent[j]) {
            if (edges[j].size() > 1) {
              ans += solve(edges[j][edges[j].size() - 2], k, l);
            }
          } else {
            ans += solve(edges[j].back(), k, l);
          }
          ans %= mod;
          x = parent[j];
          son = j;
          d = 1;
          if (edges[j].back() == parent[j]) {
            if (edges[j].size() > 1) {
              z = solve(edges[j][edges[j].size() - 2], k - 1, l);
            }
          } else {
            z = solve(edges[j].back(), k - 1, l);
          }
          while (x != 0) {
            if (l - d == 0) {
              ans += z * ways[x][l - d];
              ans %= mod;
              break;
            } else {
              ans += z * (mod + ways[x][l - d] - ways[son][l - d - 1]);
              ans %= mod;
            }
            son = x;
            x = parent[x];
            d++;
          }
        }
      }
      cout << ans << "\n";
    }
    return 0;
  }
  