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: /**
   * author: derrick20
   * created: 8/3/21 10:50 PM
   */
  import java.io.*;
  import java.util.*;
  import static java.lang.Math.*;
  
  public class F_EquidistantVertices {
      static FastScanner sc = new FastScanner();
      static PrintWriter out = new PrintWriter(System.out);
      
      public static void main(String[] args) {
          int T = sc.nextInt();
          while (T-->0) {
              int N = sc.nextInt();
              int K = sc.nextInt();
              adjList = new ArrayList[N];
              Arrays.setAll(adjList, i -> new ArrayList<>());
              for (int i = 0; i < N - 1; i++) {
                  int u = sc.nextInt() - 1, v = sc.nextInt() - 1;
                  adjList[u].add(v);
                  adjList[v].add(u);
              }
              if (K == 2) {
                  out.println(N * (N - 1) / 2);
                  continue;
              }
              long ans = 0;
              for (int node = 0; node < N; node++) {
                  long[][] depthWays = new long[K + 1][N];
                  Arrays.fill(depthWays[0], 1);
                  for (int adj : adjList[node]) { // this and prev loop sum to 2(N-1)
                      int[] branchFreq = new int[N];
                      dfs(adj, node, 0, branchFreq);
                      // then KN
                      for (int k = K; k >= 1; k--) {
                          for (int depth = 0; depth < N; depth++) {
                              depthWays[k][depth] = (depthWays[k][depth] + depthWays[k - 1][depth] * branchFreq[depth] % mod) % mod;
                          }
                      }
                  }
                  // So, O(KN^2)
                  for (int depth = 0; depth < N; depth++) {
                      ans = (ans + depthWays[K][depth]) % mod;
                  }
              }
              out.println(ans);
          }
          out.close();
      }
  
      static ArrayList<Integer>[] adjList;
      static long mod = (long) 1e9 + 7;
  
      static void dfs(int node, int par, int depth, int[] freq) {
          freq[depth]++;
          for (int adj : adjList[node]) {
              if (adj != par) {
                  dfs(adj, node, depth + 1, freq);
              }
          }
      }
  
      static class FastScanner {
          private int BS = 1 << 16;
          private char NC = (char) 0;
          private byte[] buf = new byte[BS];
          private int bId = 0, size = 0;
          private char c = NC;
          private double cnt = 1;
          private BufferedInputStream in;
      
          public FastScanner() {
              in = new BufferedInputStream(System.in, BS);
          }
      
          public FastScanner(String s) {
              try {
                  in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
              } catch (Exception e) {
                  in = new BufferedInputStream(System.in, BS);
              }
          }
      
          char getChar() {
              while (bId == size) {
                  try {
                      size = in.read(buf);
                  } catch (Exception e) {
                      return NC;
                  }
                  if (size == -1) return NC;
                  bId = 0;
              }
              return (char) buf[bId++];
          }
      
          int nextInt() {
              return (int) nextLong();
          }
      
          long nextLong() {
              cnt = 1;
              boolean neg = false;
              if (c == NC) c = getChar();
              for (; (c < '0' || c > '9'); c = getChar()) {
                  if (c == '-') neg = true;
              }
              long res = 0;
              for (; c >= '0' && c <= '9'; c = getChar()) {
                  res = (res << 3) + (res << 1) + c - '0';
                  cnt *= 10;
              }
              return neg ? -res : res;
          }
      
          double nextDouble() {
              boolean neg = false;
              if (c == NC) c = getChar();
              for (; (c < '0' || c > '9'); c = getChar()) {
                  if (c == '-') neg = true;
              }
              double cur = nextLong();
              if (c != '.') {
                  return neg ? -cur : cur;
              } else {
                  double frac = nextLong() / cnt;
                  return neg ? -cur - frac : cur + frac;
              }
          }
      
          String next() {
              StringBuilder res = new StringBuilder();
              while (c <= 32) c = getChar();
              while (c > 32) {
                  res.append(c);
                  c = getChar();
              }
              return res.toString();
          }
      
          String nextLine() {
              StringBuilder res = new StringBuilder();
              while (c <= 32) c = getChar();
              while (c != '\n') {
                  res.append(c);
                  c = getChar();
              }
              return res.toString();
          }
      
          boolean hasNext() {
              if (c > 32) return true;
              while (true) {
                  c = getChar();
                  if (c == NC) return false;
                  else if (c > 32) return true;
              }
          }
      }
      
      static void ASSERT(boolean assertion, String message) {
          if (!assertion) throw new AssertionError(message);
      }
      
      static void ASSERT(boolean assertion) {
          if (!assertion) throw new AssertionError();
      }
  }