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.util.Map.Entry;
  
  import java.math.*;
  import java.io.*;
  
  public class Main {
  	static final int mod = 1000000007;
  
  	public static void main(String[] args) throws FileNotFoundException {
  		InputReader in = new InputReader(System.in);
  		// Scanner in = new Scanner(System.in);
  		// Scanner in = new Scanner(new BufferedReader(new
  		// InputStreamReader(System.in)));
  		PrintWriter out = new PrintWriter(System.out);
  		// InputReader in = new InputReader(new
  		// File("ethan_traverses_a_tree.txt"));
  		// PrintWriter out = new PrintWriter(new
  		// File("ethan_traverses_a_tree-output.txt"));
  
  		int pi = in.nextInt();
  		for (int qi = 0; qi < pi; qi++) {
  			int n = in.nextInt();
  			int k = in.nextInt();
  
  			List<List<Integer>> g = new ArrayList<List<Integer>>();
  			for (int i = 0; i < n; i++) {
  				g.add(new ArrayList<Integer>());
  			}
  
  			for (int i = 0; i < n - 1; i++) {
  				int u = in.nextInt() - 1;
  				int v = in.nextInt() - 1;
  
  				g.get(u).add(v);
  				g.get(v).add(u);
  			}
  
  			if (k == 2) {
  				int ans = n * (n - 1) / 2;
  				out.printf("%d\n", ans);
  			} else {
  				int ans = 0;
  				for (int root = 0; root < n; root++) {
  					List<List<Integer>> tree = new ArrayList<List<Integer>>();
  					for (int i = 0; i < n; i++) {
  						tree.add(new ArrayList<Integer>());
  					}
  
  					toRootedTree(g, tree, root, -1);
  					List<List<Integer>> count = new ArrayList<List<Integer>>();
  					for (int i = 0; i < n; i++) {
  						count.add(new ArrayList<Integer>(n));
  						for (int j = 0; j < n; j++) {
  							count.get(i).add(0);
  						}
  					}
  
  					dfs(tree, root, count);
  
  					for (int i = 0; i < n; i++) {
  						List<Integer> listfordp = new ArrayList<Integer>();
  						for (Integer v : tree.get(root)) {
  							int value = count.get(v).get(i);
  							if (value > 0) {
  								listfordp.add(value);
  							}
  						}
  
  						if (listfordp.size() >= k) {
  							int nowans = dp(listfordp, k);
  							ans = (ans + nowans) % mod;
  						} else {
  							break;
  						}
  					}
  				}
  
  				out.printf("%d\n", ans);
  			}
  		}
  
  		out.close();
  	}
  
  	public static int dp(List<Integer> list, int k) {
  		int n = list.size();
  		long[][] dp = new long[n][k + 1];
  
  		for (int i = 0; i < n; i++) {
  			dp[i][0] = 1;
  			if (i == 0) {
  				dp[i][1] = list.get(i);
  			} else {
  				for (int j = 1; j <= k; j++) {
  					if (j > i + 1) {
  						break;
  					}
  
  					dp[i][j] = (dp[i - 1][j] + list.get(i) * dp[i - 1][j - 1]) % mod;
  				}
  			}
  		}
  		return (int) (dp[n - 1][k]);
  	}
  
  	public static void dfs(List<List<Integer>> tree, int now, List<List<Integer>> count) {
  		for (Integer v : tree.get(now)) {
  			dfs(tree, v, count);
  
  			for (int i = 0; i < count.get(v).size(); i++) {
  				int value = count.get(v).get(i);
  
  				if (value == 0) {
  					break;
  				}
  				count.get(now).set(i + 1, count.get(now).get(i + 1) + value);
  			}
  		}
  
  		count.get(now).set(0, 1);
  	}
  
  	public static void toRootedTree(List<List<Integer>> g, List<List<Integer>> tree, int now, int parent) {
  		for (Integer v : g.get(now)) {
  			if (v != parent) {
  				tree.get(now).add(v);
  				toRootedTree(g, tree, v, now);
  			}
  		}
  	}
  
  	static class InputReader {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public InputReader(File f) {
  			try {
  				br = new BufferedReader(new FileReader(f));
  			} catch (FileNotFoundException e) {
  				e.printStackTrace();
  			}
  		}
  
  		public InputReader(InputStream in) {
  			br = new BufferedReader(new InputStreamReader(in));
  		}
  
  		public String next() {
  			while (st == null || !st.hasMoreTokens()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  
  		public boolean hasNext() {
  			while (st == null || !st.hasMoreTokens()) {
  				String s = null;
  				try {
  					s = br.readLine();
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  				if (s == null)
  					return false;
  				st = new StringTokenizer(s);
  			}
  			return true;
  		}
  
  		public int nextInt() {
  			return Integer.parseInt(next());
  		}
  
  		public long nextLong() {
  			return Long.parseLong(next());
  		}
  
  		public double nextDouble() {
  			return Double.parseDouble(next());
  		}
  	}
  }