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: import java.util.*;
  import java.io.*;
  import static java.lang.Math.*;
  
  public class ACMIND
  {
      static FastReader scan;
      static PrintWriter pw;
      static long MOD = 1_000_000_007;
      static long INF = 2_000_000_000_000_000_000L;
      static long inf = 2_000_000_000;
      public static void main(String[] args) {
          new Thread(null,null,"_",1<<27)
          {
              public void run()
              {
                  try
                  {
                      solve();
                  }
                  catch(Exception e)
                  {
                      e.printStackTrace();
                      System.exit(1);
                  }
              }
          }.start();
      }
  
      static int n,k, freq[][];
      static ArrayList<Integer> adj[];
      static void solve() throws IOException {
          scan = new FastReader();
          pw = new PrintWriter(System.out, true);
          StringBuilder sb = new StringBuilder();
  
          //pa("ncr", ncr);
          int t = ni();
          while (t-->0) {
              n = ni();
              k = ni();
              adj = new ArrayList[n+1];
              for(int i=1;i<=n;i++) {
                  adj[i] = new ArrayList<>();
              }
  
              for(int i=1;i<n;i++) {
                  int u = ni(), v = ni();
                  adj[u].add(v);
                  adj[v].add(u);
              }
  
              long ans = 0;
              for(int i=1;i<=n;i++) {
                  freq = new int[n+1][n+1];
                  dfs(i, i);
                  // pa("freq", freq);
                  int cc = adj[i].size();
                  for(int dis=1;dis<n;++dis) {
                      long dp[][] = new long[cc+1][k+1];
                      for(int j=0;j<=cc;++j) {
                          dp[j][0] = 1;
                      }
                      for(int j=1;j<=cc;++j) {
                          int child = adj[i].get(j-1);
                          for(int left=1;left<=k;++left) {
                              dp[j][left] = dp[j-1][left] + 1L * freq[child][dis-1] * dp[j-1][left-1];
                              dp[j][left] %= MOD;
                          }
                      }
  
                      ans+=dp[cc][k];
                      if(ans>=MOD) ans-=MOD;
                  }
              }
  
              if(k==2) {
                  pl((n*(n-1))/2);
              }
              else {
                  pl(ans);
              }
          }
  
          pw.flush();
          pw.close();
      }
  
      static void dfs(int v, int par) {
          // pl("in dfs v: "+v+" par: "+par);
          freq[v][0] = 1;
          for(int e : adj[v]) {
              if(e!=par) {
                  dfs(e, v);
                  for(int i=1;i<=n;i++) {
                      // pl("e: "+e + " freq[e][i-1] : "+freq[e][i-1]);
                      freq[v][i]+=freq[e][i-1];
                  }
              }
          }
      }
  
      static void assert_in_range(String varName, int n, int l, int r) {
          if (n >=l && n<=r) return;
          System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
          System.exit(1);
      }
      static void assert_in_range(String varName, long n, long l, long r) {
          if (n>=l && n<=r) return;
          System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
          System.exit(1);
      }
  
      static int ni() throws IOException
      {
          return scan.nextInt();
      }
      static long nl() throws IOException
      {
          return scan.nextLong();
      }
      static double nd() throws IOException
      {
          return scan.nextDouble();
      }
      static void pl()
      {
          pw.println();
      }
      static void p(Object o)
      {
          pw.print(o+" ");
      }
      static void pl(Object o)
      {
          pw.println(o);
      }
      static void psb(StringBuilder sb)
      {
          pw.print(sb);
      }
      static void pa(String arrayName, Set<Object> set)
      {
          pl(arrayName+" : ");
          for(Object o : set)
              p(o);
          pl();
      }
      static void pa(String arrayName, Object arr[])
      {
          pl(arrayName+" : ");
          for(Object o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, int arr[])
      {
          pl(arrayName+" : ");
          for(int o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, long arr[])
      {
          pl(arrayName+" : ");
          for(long o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, double arr[])
      {
          pl(arrayName+" : ");
          for(double o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, char arr[])
      {
          pl(arrayName+" : ");
          for(char o : arr)
              p(o);
          pl();
      }
      static void pa(String listName, List list)
      {
          pl(listName+" : ");
          for(Object o : list)
              p(o);
          pl();
      }
      static void pa(String arrayName, Object[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(Object o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, int[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(int o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, long[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(long o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, char[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(char o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, double[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(double o : arr[i])
                  p(o);
              pl();
          }
      }
      static class FastReader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
  
          public FastReader() {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public FastReader(String file_name) throws IOException {
              din = new DataInputStream(new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public String readLine() throws IOException {
              byte[] buf = new byte[1000000];
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') break;
                  buf[cnt++] = (byte) c;
              }
              return new String(buf, 0, cnt);
          }
  
          public int nextInt() throws IOException {
              int ret = 0;
              byte c = read();
              while (c <= ' ') c = read();
              boolean neg = (c == '-');
              if (neg) c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg) return -ret;
              return ret;
          }
  
          public long nextLong() throws IOException {
              long ret = 0;
              byte c = read();
              while (c <= ' ') c = read();
              boolean neg = (c == '-');
              if (neg) c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg) return -ret;
              return ret;
          }
  
          public double nextDouble() throws IOException {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ') c = read();
              boolean neg = (c == '-');
              if (neg) c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
              if (neg) return -ret;
              return ret;
          }
  
          private void fillBuffer() throws IOException {
              bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
              if (bytesRead == -1) buffer[0] = -1;
          }
  
          private byte read() throws IOException {
              if (bufferPointer == bytesRead) fillBuffer();
              return buffer[bufferPointer++];
          }
  
          public void close() throws IOException {
              if (din == null) return;
              din.close();
          }
      }
  }