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.*;
  import java.math.BigInteger;
  import java.util.InputMismatchException;
  
  public class Main {
  	static PrintWriter out;
  	static Reader in;
  	public static void main(String[] args) throws IOException {
  		input_output();
  		Main solver = new Main();
  		solver.solve();
  		out.close();
  
  		out.flush();
  	} 
  
  	static long INF = (long)1e18;
  	static int MAXN = (int)1e5 + 5;
  	static int MOD = (int)1e9 + 7;
  	static int q, t, n, m, k;
  	static double pi = Math.PI;
  
  	static List<Integer> adj[];
  	static long ans;
  
  	void solve() throws IOException {
  		t = in.nextInt();
  		
  		while (t --> 0) {
  			n = in.nextInt();
  			k = in.nextInt();
  
  			adj = new ArrayList[n+1];
  			for (int i = 1; i <= n; i++) adj[i] = new ArrayList<Integer>();
  
  			for (int i = 0; i < n-1; i++) {
  				int u = in.nextInt(),
  					v = in.nextInt();
  				adj[u].add(v);
  				adj[v].add(u);
  			}
  
  			ans = 0;
  
  			if (k == 2) {
  				ans = (((long)n*(n-1))/2L)%MOD;
  				out.println(ans);
  				continue;
  			}
  			int[] par = new int[n+1];
  			int[][] down = new int[n+1][n+1],
  				    up   = new int[n+1][n+1];
  			
  			boolean[] vis = new boolean[n+1];
  			DFS_DOWN(1, vis, down, par);
  			vis = new boolean[n+1];
  			BFS_UP(1, vis, up, down, par);
  
  			long[] res = new long[k+1];
  			res[0] = 1;
  			for (int root = 1; root <= n; root++) {
  				for (int depth = 1; depth < n; depth++) {
  					for (int i = 1; i <= k; i++) res[i] = 0;
  
  					for (int e: adj[root]) {
  						if (e != par[root]) {
  							for (int i = k; i >= 1; i--) {
  								res[i] = (res[i] + (res[i-1]*down[e][depth-1])%MOD)%MOD;
  							}
  						} else {
  							for (int i = k; i >= 1; i--) {
  								res[i] = (res[i] + (res[i-1]*up[root][depth])%MOD)%MOD;
  							}
  						}
  					}
  					ans = (ans + res[k])%MOD;
  				}
  			}
  
  			out.println(ans);
  		}	
  	}
  
  	static void BFS_UP(int s, boolean[] vis, int[][] up, int[][] down, int[] par) {
  		ArrayDeque<Integer> dq = new ArrayDeque<>();
  		dq.add(s);
  		vis[s] = true;
  
  		while (dq.size() != 0) {
  			int e = dq.pollFirst();
  			up[e][0] = 1;
  			for (int i = 0; i < n; i++) {
  				up[e][i+1] += down[par[e]][i]+up[par[e]][i]-(i == 0 || e == 1 ? 0: down[e][i-1])-(i == 0 && e != 1 ? 1: 0);
  			}
  
  			for (int ee: adj[e]) {
  				if (!vis[ee]) {
  					vis[ee] = true;
  					dq.addLast(ee);
  				}
  			}
  		}
  	}
  
  	static void DFS_DOWN(int s, boolean[] vis, int[][] down, int[] par) {
  		vis[s] = true;
  		down[s][0] = 1;
  
  		for (int e: adj[s]) {
  			if (vis[e]) continue;
  			par[e] = s;
  			DFS_DOWN(e, vis, down, par);
  			for (int i = 0; i < n; i++) down[s][i+1] += down[e][i];
  		}
  	}
  
  	static class Reader {
  		private InputStream mIs;
  		private byte[] buf = new byte[1024];
  		private int curChar;
  		private int numChars;
  
  		public Reader() {
  			this(System.in);
  		}
  
  		public Reader(InputStream is) {
  			mIs = is;
  		}
  
  		public int read() {
  			if (numChars == -1) {
  				throw new InputMismatchException();
  
  			}
  			if (curChar >= numChars) {
  				curChar = 0;
  				try {
  					numChars = mIs.read(buf);
  				} catch (IOException e) {
  					throw new InputMismatchException();
  				}
  				if (numChars <= 0) {
  					return -1;
  				}
  			}
  			return buf[curChar++];
  		}
  
  		public String nextLine() {
  			int c = read();
  			while (isSpaceChar(c)) {
  				c = read();
  			}
  			StringBuilder res = new StringBuilder();
  			do {
  				res.appendCodePoint(c);
  				c = read();
  			} while (!isEndOfLine(c));
  			return res.toString();
  		}
  
  		public String next() {
  			int c = read();
  			while (isSpaceChar(c)) {
  				c = read();
  			}
  			StringBuilder res = new StringBuilder();
  			do {
  				res.appendCodePoint(c);
  				c = read();
  			} while (!isSpaceChar(c));
  			return res.toString();
  		}
  
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  
  		public long nextLong() {
  			int c = read();
  			while (isSpaceChar(c)) {
  				c = read();
  			}
  			int sgn = 1;
  			if (c == '-') {
  				sgn = -1;
  				c = read();
  			}
  			long res = 0;
  			do {
  				if (c < '0' || c > '9') {
  					throw new InputMismatchException();
  				}
  				res *= 10;
  				res += c - '0';
  				c = read();
  			} while (!isSpaceChar(c));
  			return res * sgn;
  		}
  
  		public int nextInt() {
  			int c = read();
  			while (isSpaceChar(c)) {
  				c = read();
  			}
  			int sgn = 1;
  			if (c == '-') {
  				sgn = -1;
  				c = read();
  			}
  			int res = 0;
  			do {
  				if (c < '0' || c > '9') {
  					throw new InputMismatchException();
  				}
  				res *= 10;
  				res += c - '0';
  				c = read();
  			} while (!isSpaceChar(c));
  			return res * sgn;
  		}
  
  		public boolean isSpaceChar(int c) {
  			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  		}
  
  		public boolean isEndOfLine(int c) {
  			return c == '\n' || c == '\r' || c == -1;
  		}
  
  	}
  	static void input_output() throws IOException {
  		File f = new File("in.txt");
  		if (f.exists() && !f.isDirectory()) {
  			in = new Reader(new FileInputStream("in.txt"));
  		} else in = new Reader();
  		f = new File("out.txt");
  		if (f.exists() && !f.isDirectory()) {
  			out = new PrintWriter(new File("out.txt"));
  		} else out = new PrintWriter(System.out);
  	}
  }