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;
  void __print(int x) { cerr << x; }
  void __print(long x) { cerr << x; }
  void __print(long long x) { cerr << x; }
  void __print(unsigned x) { cerr << x; }
  void __print(unsigned long x) { cerr << x; }
  void __print(unsigned long long x) { cerr << x; }
  void __print(float x) { cerr << x; }
  void __print(double x) { cerr << x; }
  void __print(long double x) { cerr << x; }
  void __print(char x) { cerr << '\'' << x << '\''; }
  void __print(const char *x) { cerr << '\"' << x << '\"'; }
  void __print(const string &x) { cerr << '\"' << x << '\"'; }
  void __print(bool x) { cerr << (x ? "true" : "false"); }
  template <typename T, typename V>
  void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
  }
  template <typename T>
  void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
  }
  void _print() { cerr << "]\n"; }
  template <typename T, typename... V>
  void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
  }
  const long long oo = 1e18;
  const long double eps = 1e-9;
  const string yes = "YES";
  const string no = "NO";
  const long double PI = acos(-1.0);
  void io(long long x) {
    if (!x) {
      freopen(
          "1551f"
          ".inp",
          "r", stdin);
      return;
    }
    if (x == 1) {
      freopen(
          "1551f"
          ".inp",
          "r", stdin);
      freopen(
          "1551f"
          ".out",
          "w", stdout);
      return;
    }
    freopen(
        "1551f"
        ".out",
        "w", stdout);
  }
  long long n, k;
  const long long N = 105;
  vector<long long> g[N];
  long long dp[N][N];
  vector<long long> cnt(N);
  const long long MOD = 1e9 + 7;
  long long fast_pow(long long a, long long b) {
    long long res = 1;
    for (; b; b /= 2) {
      if (b & 1) {
        ((res *= a) %= MOD);
        b--;
      }
      ((a *= a) %= MOD);
    }
    return res;
  }
  long long inv(long long x) { return fast_pow(x, MOD - 2); }
  void add(long long &a, long long b) { (a += b) %= MOD; }
  void sub(long long &a, long long b) { (a -= b - MOD) %= MOD; }
  void mul(long long &a, long long b) { (a *= b) %= MOD; }
  void div(long long &a, long long b) { (a *= inv(b)) %= MOD; }
  void init(long long x) {
    for (long long i = 0; i <= x; i++) {
      g[i].clear();
    }
  }
  void dfs(long long u, long long pre, long long d, vector<long long> &cnt) {
    cnt[d + 1]++;
    for (long long v : g[u]) {
      if (v ^ pre) dfs(v, u, d + 1, cnt);
    }
  }
  void solve() {
    cin >> n >> k;
    init(n);
    for (long long i = 1; i < n; i++) {
      long long x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    if (k == 2) {
      cout << (n * (n - 1)) / 2 << '\n';
      return;
    }
    long long ans = 0;
    for (long long u = 1; u <= n; u++) {
      for (long long i = 0; i <= n; i++) {
        for (long long j = 0; j <= n; j++) {
          dp[i][j] = 0;
          dp[0][j] = 1;
        }
      }
      for (long long v : g[u]) {
        for (long long i = 0; i <= n; i++) {
          cnt[i] = 0;
        }
        dfs(v, u, 0, cnt);
        for (long long i = k; i; i--) {
          for (long long d = 1; d <= n; d++) {
            add(dp[i][d], (dp[i - 1][d] * cnt[d]) % MOD);
          }
        }
      }
      for (long long d = 1; d <= n; d++) {
        add(ans, dp[k][d]);
      }
    }
    cout << ans << '\n';
  }
  signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long test_case = 1;
    cin >> test_case;
    for (long long tt = 1; tt <= test_case; tt++) {
      solve();
    }
    return 0;
  }
  