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
  
  
  class SegmentTree:
      def __init__(self, array):
          self.n = len(array)
          self.size = 1
          while self.size < self.n:
              self.size *= 2
          self.func = lambda x, y: x if x[0] < y[0] else y
          self.default = (10 ** 9, -1)
          self.data = [self.default] * (2 * self.size)
          self.process(array)
      
      def process(self, array):
          self.data[self.size: self.size + self.n] = array
          for i in range(self.size - 1, -1, -1):
              self.data[i] = self.func(self.data[2 * i], self.data[2 * i + 1])
      
      def query(self, alpha, omega):
          """Returns the result of function over the range (inclusive)!"""
          if alpha == omega:
              return self.data[alpha + self.size]
          res = self.default
          alpha += self.size
          omega += self.size + 1
          while alpha < omega:
              if alpha & 1:
                  res = self.func(res, self.data[alpha])
                  alpha += 1
              if omega & 1:
                  omega -= 1
                  res = self.func(res, self.data[omega])
              alpha >>= 1
              omega >>= 1
          return res
      
      def update(self, index, value):
          """Updates the element at index to given value!"""
          index += self.size
          self.data[index] = value
          index >>= 1
          while index:
              self.data[index] = self.func(self.data[2 * index], self.data[2 * index + 1])
              index >>= 1
  
  
  class LCA:
      def __init__(self, graph, root):
          self.graph = graph
          self.n = len(graph)
          self.euler = []
          self.first = [-1] * self.n
          self.st = None
          self.process(root)
      
      def process(self, root):
          visited, parents, heights = [False] * self.n, [-1] * self.n, [1] * self.n
          stack = [root]
          while stack:
              v = stack[-1]
              if not visited[v]:
                  visited[v] = True
                  self.euler += [v]
                  if self.first[v] == -1:
                      self.first[v] = len(self.euler) - 1
                  for u in self.graph[v]:
                      if not visited[u]:
                          stack.append(u)
                          parents[u], heights[u] = v, heights[v] + 1
              else:
                  self.euler += [parents[stack.pop()]]
          self.euler = [(heights[k], k) for k in self.euler]
          self.st = SegmentTree(self.euler)
      
      def query(self, x, y):
          """Returns the lowest common ancestor of nodes x and y!"""
          p, q = min(self.first[x], self.first[y]), max(self.first[x], self.first[y])
          return self.st.query(p, q)[1]
  
  
  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
  
  
  def shortest_path(graph, alpha, omega):
      """Returns the shortest path between two vertices!"""
      used, dist, parents = bfs(graph, alpha)
      if not used[omega]:
          return []
      path = [omega]
      v = omega
      while parents[v] != -1:
          path += [parents[v]]
          v = parents[v]
      return path[::-1]
  
  
  max_n=200
  mod=10 ** 9 + 7
  if 1:
      max_n = min(max_n, mod - 1)
      
      fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)
      fact[0] = 1
      for i in range(max_n):
          fact[i + 1] = fact[i] * (i + 1) % mod
      
      inv_fact[-1] = pow(fact[-1], mod - 2, mod)
      for i in reversed(range(max_n)):
          inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod
      
      def nCr_mod(n, r):
          res = 1
          while n or r:
              a, b = n % mod, r % mod
              if a < b:
                  return 0
              res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
              n //= mod
              r //= mod
          return res
  
  
  def sumOfProduct(arr, n, k):
      # Initialising all the values to 0
      dp = [[0 for x in range(n + 1)] for y in range(n + 1)]
      cur_sum = 0
      
      # For k = 1, the answer will simply
      # be the sum of all the elements
      for i in range(1, n + 1):
          dp[1][i] = arr[i - 1]
          cur_sum += arr[i - 1]
      
      # Filling the table in bottom up manner
      for i in range(2, k + 1):
          
          # To store the elements of the current
          # row so that we will be able to use this sum
          # for subsequent values of k
          temp_sum = 0
          
          for j in range(1, n + 1):
              # We will subtract previously computed value
              # so as to get the sum of elements from j + 1
              # to n in the (i - 1)th row
              cur_sum -= dp[i - 1][j]
              
              dp[i][j] = arr[j - 1] * cur_sum
              dp[i][j] %= mod
              temp_sum += dp[i][j]
          cur_sum = temp_sum
      return cur_sum % mod
  
  from random import randint
      
  for _ in range(int(input()) if True else 1):
      ok = 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()
      graph = [[] for _ in range(n+1)]
      for i in range(n-1):
          x, y = map(int, input().split())
          graph[x] += [y]
          graph[y] += [x]
      if k == 2:
          ans = (n * (n-1)) // 2
          print(ans % mod)
          continue
      
      
      ans = 0
      for i in range(1, n+1):
          count = [[0]*(n+7) for _ in range(n +1)]
          dist, parents = bfs(graph, i)
          one = 0
          for j in range(1, n+1):
              if dist[j] == 1:one += 1
              elif dist[j] != 0:
                  x = j
                  while parents[x] != i:
                      x = parents[x]
                  count[dist[j]][x] += 1
                  
          for x in count:
              p = []
              for y in x:
                  if y:
                      p+=[y]
              if len(p) >= k:
                  #print(i,p)
                  ans += sumOfProduct(p, len(p), k)
                  ans %= mod
          ans += nCr_mod(one, k)
      
      print(ans % mod)