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: # ------------------- fast io --------------------
  import os
  import sys
  from io import BytesIO, IOBase
  
  BUFSIZE = 8192
  
  
  class FastIO(IOBase):
      newlines = 0
      
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
      
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
      
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
      
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  
  # ------------------- fast io --------------------
  from math import ceil
  
  
  def prod(a, mod=10 ** 9 + 7):
      ans = 1
      for each in a:
          ans = (ans * each) % mod
      return ans
  
  
  def gcd(x, y):
      while y:
          x, y = y, x % y
      return x
  
  
  def lcm(a, b): return a * b // gcd(a, b)
  
  
  def binary(x, length=16):
      y = bin(x)[2:]
      return y if len(y) >= length else "0" * (length - len(y)) + y
  
  
  from collections import deque
  
  def bfs(graph, alpha=0):
      """Breadth first search on a graph!"""
      n = len(graph)
      q = deque([alpha])
      used = [False] * n
      used[alpha] = True
      dist, parents = [0] * n, [-1] * n
      while q:
          v = q.popleft()
          for u in graph[v]:
              if not used[u]:
                  used[u] = True
                  q.append(u)
                  dist[u] = dist[v] + 1
                  parents[u] = v
      return dist, parents
  
  for _ in range(int(input()) if True else 1):
      empty = input()
      n, k = map(int, input().split())
      # a, b = map(int, input().split())
      # c, d = map(int, input().split())
      # a = list(map(int, input().split()))
      # b = list(map(int, input().split()))
      # s = input()
      mod = 10**9 + 7
      
      graph = [[] for i in range(n + 1)]
      for __ in range(n-1):
          x, y = map(int, input().split())
          graph[x] += [y]
          graph[y] += [x]
  
      if k == 2:
          print((n * (n - 1)) // 2)
          continue
          
      ans = 0
      for root in range(1, n + 1):
          dist, parents = bfs(graph, root)
          check = [[0]*(n + 1) for p in range(n+1)]
          for i in range(1, n + 1):
              if i == root: continue
              x = i
              while parents[x] != root:
                  x = parents[x]
              check[dist[i]][x] += 1
          
          for b in check:
              a = [x for x in b if x]
              if len(a) < k: continue
              # dp[i] = sum of every i elements
              dp = [0] * (k + 1)
              dp[0] = 1
              for i in range(len(a)):
                  dp2 = [0] * (k + 1)
                  dp2[0] = 1
                  for j in range(1, k + 1):
                      dp2[j] = (dp[j] + dp[j-1] * a[i]) % mod
                  dp = list(dp2)
              ans = (ans + dp[-1]) % mod
      
      print(ans)