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.io.*;
  import java.util.*;
  
  public class Main {
  	public static void main(String[] args) {
  		InputStream inputStream = System.in;
  		OutputStream outputStream = System.out;
  		InputReader in = new InputReader(inputStream);
  		PrintWriter out = new PrintWriter(outputStream);
  		Task solver = new Task();
  		int tcCnt = in.nextInt();
  		for (int tc = 1; tc <= tcCnt; tc++)
  			solver.solve(tc, in, out);
  		out.close();
  	}
  
  	static class Task {
  		final long MOD = (long)(1e9 + 7);
  		int n, k;
  		List<Integer>[] list;
  		public void solve(int testNumber, InputReader in, PrintWriter out) {
  			n = in.nextInt();
  			k = in.nextInt();
  			list = new ArrayList[n+1];
  			for (int i = 1; i <= n; i++) {
  				list[i] = new ArrayList<Integer>();
  			}
  			for (int i = 1; i < n; i++) {
  				int u = in.nextInt();
  				int v = in.nextInt();
  				list[u].add(v);
  				list[v].add(u);
  			}
  			if (k == 2) {
  				out.println(((1l * n * (n-1)) / 2) % MOD);
  				return;
  			}
  			long ans = 0;
  			for (int i = 1; i <= n; i++) {
  				ans = (ans + noOfSets(i)) % MOD;
  			}
  			out.println(ans);
  		}
  		long noOfSets(int node) {
  			Queue<Integer> queue = new LinkedList<>();
  			int[] subtreeIndex = new int[n+1];
  			subtreeIndex[node] = -1;
  			for (int i = 0; i < list[node].size(); i++) {
  				int next = list[node].get(i);
  				subtreeIndex[next] = i+1;
  				queue.add(next);
  			}
  
  			int nn = list[node].size();
  			int[] cnt = new int[nn+1];
  			Arrays.fill(cnt, 1);
  
  			// dp[i][j] is the number of sets of length j from the first i subtrees
  			long[][] dp = new long[nn+1][k+1];
  			long ans = 0;
  
  			while(!queue.isEmpty()) {
  
  				for (int i = 0; i <= nn; i++) {
  					for (int j = 0; j <= i && j <= k; j++) {
  						if (i == 0) {
  							if (j == 0) {
  								dp[i][j] = 1;
  							} else {
  								dp[i][j] = 0;
  							}
  						} else {
  							dp[i][j] = (dp[i-1][j] + (j > 0 ? (dp[i-1][j-1] * cnt[i]) % MOD : 0)) % MOD;
  						}
  					}
  				}
  
  				ans = (ans + dp[nn][k]) % MOD;
  
  				for (int i = queue.size(); i > 0 ; i--) {
  					int curr = queue.remove();
  					cnt[subtreeIndex[curr]]--;
  					for (int next: list[curr]) {
  						if (subtreeIndex[next] == 0) {
  							cnt[subtreeIndex[curr]]++;
  							subtreeIndex[next] = subtreeIndex[curr];
  							queue.add(next);
  						}
  					}
  				}
  			}
  			return ans;
  		}
  
  	}
  
  	static class InputReader {
  		public BufferedReader reader;
  		public StringTokenizer tokenizer;
  
  		public InputReader(InputStream stream) {
  			reader = new BufferedReader(new InputStreamReader(stream), 32768);
  			tokenizer = null;
  		}
  
  		public String nextLine() {
  			try {
  				return reader.readLine();
  			} catch (IOException e) {
  				throw new RuntimeException(e);
  			}
  		}
  
  		public String nextToken() {
  			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  				tokenizer = new StringTokenizer(nextLine());
  			}
  			return tokenizer.nextToken();
  		}
  
  		public int nextInt() {
  			return Integer.parseInt(nextToken());
  		}
  
  		public double nextDouble() {
  			return Double.parseDouble(nextToken());
  		}
  
  		public long nextLong() {
  			return Long.parseLong(nextToken());
  		}
  
  		public int[] nextIntArray(int size) {
  			int[] arr = new int[size];
  			for (int i = 0; i < size; i++) {
  				arr[i] = nextInt();
  			}
  			return arr;
  		}
  
  	}
  }