#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int modadd(int x, int y) {
  int result = x + y;
  if (result >= MOD) result -= MOD;
  return result;
}
int modmult(int x, int y) { return (x * int64_t(y)) % MOD; }
int modaddto(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int64_t modpow(int64_t b, int64_t e) {
  int64_t ans = 1;
  for (; e; b = b * b % MOD, e /= 2)
    if (e & 1) ans = ans * b % MOD;
  return ans;
}
int modinv(int x) { return modpow(x, MOD - 2); }
vector<int> get_parents(const vector<vector<int>>& adj, int root) {
  int n = adj.size();
  vector<int> parents(n, -1);
  stack<pair<int, int>> st;
  st.emplace(root, -1);
  while (!st.empty()) {
    int node = st.top().first;
    parents[node] = st.top().second;
    st.pop();
    for (int i : adj[node]) {
      if (i != parents[node]) {
        st.emplace(i, node);
      }
    }
  }
  return parents;
}
vector<vector<int>> get_children(const vector<int>& parents) {
  int n = parents.size();
  vector<vector<int>> children(n);
  for (int i = 0; i < n; ++i) {
    if (parents[i] >= 0) {
      children[parents[i]].push_back(i);
    }
  }
  return children;
}
vector<int> get_depth(const vector<vector<int>>& children, int root) {
  int n = children.size();
  vector<int> depth(n);
  vector<int> q(1, root);
  int d = 0;
  while (!q.empty()) {
    vector<int> q2;
    for (int i : q) {
      depth[i] = d;
      for (int j : children[i]) {
        q2.push_back(j);
      }
    }
    q2.swap(q);
    d++;
  }
  return depth;
}
int solve(const vector<int>& u, const vector<int>& v, int k) {
  int n = u.size() + 1;
  if (k == 2) {
    return n * (n - 1) / 2;
  }
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; ++i) {
    adj[u[i]].push_back(v[i]);
    adj[v[i]].push_back(u[i]);
  }
  int ways = 0;
  for (int root = 0; root < n; ++root) {
    if (int(adj[root].size()) < k) continue;
    vector<int> parents = get_parents(adj, root);
    vector<vector<int>> children = get_children(parents);
    vector<int> depth = get_depth(children, root);
    int max_depth = *max_element(depth.begin(), depth.end());
    int nch = children[root].size();
    vector<vector<int>> depths(nch, vector<int>(max_depth, 0));
    for (int chi = 0; chi < nch; ++chi) {
      stack<int> st;
      st.push(children[root][chi]);
      while (!st.empty()) {
        int node = st.top();
        st.pop();
        depths[chi][depth[node] - 1]++;
        for (int j : children[node]) {
          st.push(j);
        }
      }
    }
    for (int d = 0; d < max_depth; ++d) {
      vector<int> dp(1, 1);
      for (int chi = 0; chi < nch; ++chi) {
        vector<int> dp2(chi + 2, 0);
        dp2[0] = dp[0];
        for (int i = 1; i < chi + 2; ++i) {
          dp2[i] = (i < chi + 1) ? dp[i] : 0;
          modaddto(dp2[i], modmult(dp[i - 1], depths[chi][d]));
        }
        dp2.swap(dp);
      }
      assert(int(dp.size()) > k);
      modaddto(ways, dp[k]);
    }
  }
  return ways;
}
void test_case() {
  int n, k;
  cin >> n >> k;
  vector<int> u(n - 1), v(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> u[i] >> v[i];
    --u[i];
    --v[i];
  }
  cout << solve(u, v, k) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    test_case();
  }
}

### Prompt

Generate a CPP solution to 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>
using namespace std;
const int MOD = 1e9 + 7;
int modadd(int x, int y) {
  int result = x + y;
  if (result >= MOD) result -= MOD;
  return result;
}
int modmult(int x, int y) { return (x * int64_t(y)) % MOD; }
int modaddto(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int64_t modpow(int64_t b, int64_t e) {
  int64_t ans = 1;
  for (; e; b = b * b % MOD, e /= 2)
    if (e & 1) ans = ans * b % MOD;
  return ans;
}
int modinv(int x) { return modpow(x, MOD - 2); }
vector<int> get_parents(const vector<vector<int>>& adj, int root) {
  int n = adj.size();
  vector<int> parents(n, -1);
  stack<pair<int, int>> st;
  st.emplace(root, -1);
  while (!st.empty()) {
    int node = st.top().first;
    parents[node] = st.top().second;
    st.pop();
    for (int i : adj[node]) {
      if (i != parents[node]) {
        st.emplace(i, node);
      }
    }
  }
  return parents;
}
vector<vector<int>> get_children(const vector<int>& parents) {
  int n = parents.size();
  vector<vector<int>> children(n);
  for (int i = 0; i < n; ++i) {
    if (parents[i] >= 0) {
      children[parents[i]].push_back(i);
    }
  }
  return children;
}
vector<int> get_depth(const vector<vector<int>>& children, int root) {
  int n = children.size();
  vector<int> depth(n);
  vector<int> q(1, root);
  int d = 0;
  while (!q.empty()) {
    vector<int> q2;
    for (int i : q) {
      depth[i] = d;
      for (int j : children[i]) {
        q2.push_back(j);
      }
    }
    q2.swap(q);
    d++;
  }
  return depth;
}
int solve(const vector<int>& u, const vector<int>& v, int k) {
  int n = u.size() + 1;
  if (k == 2) {
    return n * (n - 1) / 2;
  }
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; ++i) {
    adj[u[i]].push_back(v[i]);
    adj[v[i]].push_back(u[i]);
  }
  int ways = 0;
  for (int root = 0; root < n; ++root) {
    if (int(adj[root].size()) < k) continue;
    vector<int> parents = get_parents(adj, root);
    vector<vector<int>> children = get_children(parents);
    vector<int> depth = get_depth(children, root);
    int max_depth = *max_element(depth.begin(), depth.end());
    int nch = children[root].size();
    vector<vector<int>> depths(nch, vector<int>(max_depth, 0));
    for (int chi = 0; chi < nch; ++chi) {
      stack<int> st;
      st.push(children[root][chi]);
      while (!st.empty()) {
        int node = st.top();
        st.pop();
        depths[chi][depth[node] - 1]++;
        for (int j : children[node]) {
          st.push(j);
        }
      }
    }
    for (int d = 0; d < max_depth; ++d) {
      vector<int> dp(1, 1);
      for (int chi = 0; chi < nch; ++chi) {
        vector<int> dp2(chi + 2, 0);
        dp2[0] = dp[0];
        for (int i = 1; i < chi + 2; ++i) {
          dp2[i] = (i < chi + 1) ? dp[i] : 0;
          modaddto(dp2[i], modmult(dp[i - 1], depths[chi][d]));
        }
        dp2.swap(dp);
      }
      assert(int(dp.size()) > k);
      modaddto(ways, dp[k]);
    }
  }
  return ways;
}
void test_case() {
  int n, k;
  cin >> n >> k;
  vector<int> u(n - 1), v(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> u[i] >> v[i];
    --u[i];
    --v[i];
  }
  cout << solve(u, v, k) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    test_case();
  }
}

```