#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
long long md = 1000000007;
using namespace std;
template <typename T>
T pw(T a, T b) {
  T c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m);
    m = (m * m), b /= 2;
  }
  return c;
}
template <typename T>
T ceel(T a, T b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
template <typename T>
T my_log(T n, T b) {
  T i = 1, ans = 0;
  while (1) {
    if (i > n) {
      ans--;
      break;
    }
    if (i == n) break;
    i *= b, ans++;
  }
  return ans;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwmd(long long a, long long b) {
  long long c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m) % md;
    m = (m * m) % md;
    b /= 2;
  }
  return c;
}
long long modinv(long long n) { return pwmd(n, md - 2); }
long long inverse(long long i) {
  if (i == 1) return 1;
  return (md - ((md / i) * inverse(md % i)) % md + md) % md;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long t, n, k, x, y, h = 0;
vector<long long> adj[101], vis(101), dist(101);
long long dis[101][101];
void dfs(long long u) {
  vis[u] = 1;
  for (auto s : adj[u]) {
    if (vis[s]) continue;
    dist[s] = dist[u] + 1;
    dis[dist[s]][h]++;
    dfs(s);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (long long i = 0; i < n + 1; i++) adj[i].clear();
    for (long long i = 0; i < n - 1; i++)
      cin >> x >> y, adj[x].push_back(y), adj[y].push_back(x);
    if (k == 2) {
      cout << (n * (n - 1)) / 2 << "\n";
      continue;
    }
    long long ans = 0;
    for (long long i = 1; i < n + 1; i++) {
      for (long long j = 1; j < n + 1; j++) vis[j] = 0;
      if (adj[i].size() < k) continue;
      long long o = adj[i].size();
      h = 0;
      for (long long j = 0; j < n + 1; j++)
        for (long long p = 0; p < o; p++) dis[j][p] = 0;
      for (auto w : adj[i]) {
        dist[w] = 1;
        dis[1][h]++;
        for (long long p = 0; p < n + 1; p++) vis[p] = 0;
        vis[i] = 1;
        dfs(w), h++;
      }
      for (long long j = 1; j < n + 1; j++) {
        vector<long long> v;
        for (long long p = 0; p < o; p++) {
          if (dis[j][p]) v.push_back(dis[j][p]);
        }
        if (v.size() < k) continue;
        long long g = v.size();
        long long dp[g][k + 1];
        for (long long dd = 0; dd < g; dd++)
          for (long long tt = 0; tt < k + 1; tt++) dp[dd][tt] = 0;
        dp[0][0] = 1, dp[0][1] = v[0];
        for (long long dd = 1; dd < g; dd++) {
          dp[dd][0] = 1;
          for (long long tt = 1; tt < k + 1; tt++) {
            dp[dd][tt] += dp[dd - 1][tt];
            dp[dd][tt] %= md;
            dp[dd][tt] += (dp[dd - 1][tt - 1] * v[dd]) % md;
            dp[dd][tt] %= md;
          }
        }
        ans = (ans + dp[g - 1][k]) % md;
      }
    }
    cout << ans << "\n";
  }
}

### Prompt

Create a solution in cpp for the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
long long md = 1000000007;
using namespace std;
template <typename T>
T pw(T a, T b) {
  T c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m);
    m = (m * m), b /= 2;
  }
  return c;
}
template <typename T>
T ceel(T a, T b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
template <typename T>
T my_log(T n, T b) {
  T i = 1, ans = 0;
  while (1) {
    if (i > n) {
      ans--;
      break;
    }
    if (i == n) break;
    i *= b, ans++;
  }
  return ans;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwmd(long long a, long long b) {
  long long c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m) % md;
    m = (m * m) % md;
    b /= 2;
  }
  return c;
}
long long modinv(long long n) { return pwmd(n, md - 2); }
long long inverse(long long i) {
  if (i == 1) return 1;
  return (md - ((md / i) * inverse(md % i)) % md + md) % md;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long t, n, k, x, y, h = 0;
vector<long long> adj[101], vis(101), dist(101);
long long dis[101][101];
void dfs(long long u) {
  vis[u] = 1;
  for (auto s : adj[u]) {
    if (vis[s]) continue;
    dist[s] = dist[u] + 1;
    dis[dist[s]][h]++;
    dfs(s);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (long long i = 0; i < n + 1; i++) adj[i].clear();
    for (long long i = 0; i < n - 1; i++)
      cin >> x >> y, adj[x].push_back(y), adj[y].push_back(x);
    if (k == 2) {
      cout << (n * (n - 1)) / 2 << "\n";
      continue;
    }
    long long ans = 0;
    for (long long i = 1; i < n + 1; i++) {
      for (long long j = 1; j < n + 1; j++) vis[j] = 0;
      if (adj[i].size() < k) continue;
      long long o = adj[i].size();
      h = 0;
      for (long long j = 0; j < n + 1; j++)
        for (long long p = 0; p < o; p++) dis[j][p] = 0;
      for (auto w : adj[i]) {
        dist[w] = 1;
        dis[1][h]++;
        for (long long p = 0; p < n + 1; p++) vis[p] = 0;
        vis[i] = 1;
        dfs(w), h++;
      }
      for (long long j = 1; j < n + 1; j++) {
        vector<long long> v;
        for (long long p = 0; p < o; p++) {
          if (dis[j][p]) v.push_back(dis[j][p]);
        }
        if (v.size() < k) continue;
        long long g = v.size();
        long long dp[g][k + 1];
        for (long long dd = 0; dd < g; dd++)
          for (long long tt = 0; tt < k + 1; tt++) dp[dd][tt] = 0;
        dp[0][0] = 1, dp[0][1] = v[0];
        for (long long dd = 1; dd < g; dd++) {
          dp[dd][0] = 1;
          for (long long tt = 1; tt < k + 1; tt++) {
            dp[dd][tt] += dp[dd - 1][tt];
            dp[dd][tt] %= md;
            dp[dd][tt] += (dp[dd - 1][tt - 1] * v[dd]) % md;
            dp[dd][tt] %= md;
          }
        }
        ans = (ans + dp[g - 1][k]) % md;
      }
    }
    cout << ans << "\n";
  }
}

```