#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <math.h>
#include <cstdlib>
#include <memory.h>
#include <queue>
#include <assert.h>
#include <cmath>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define sz(A) ((int)(A).size())
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define foran(i, a, n) for (int i = int(a); i < int(n); i++)
#define y1 gftxdtrtfhyjfctrxujkvbhyjice
#define y0 ehfoiuvhefroerferjhfjkehfjke
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
const double EPS = 1e-9;
const int MAXN = 70;
vector <int> g[MAXN];
int max_depth[MAXN];
int max_diam[MAXN];
ll ans[MAXN][MAXN][MAXN];//vertex, diameter, max_depth
ll dp[MAXN][MAXN][MAXN];//pos, diameter, max_depth
int n, k;
ll res;
void dfs (int v, int p = -1) {
forn(i, sz(g[v])) {
int to = g[v][i];
if (to == p)
continue;
dfs(to, v);
}
memset (dp, 0, sizeof dp);
dp[0][0][0] = 1ll;
max_diam[v] = 0;
int max_depth1 = 0, max_depth2 = 0;
for (int i = 0; i < sz(g[v]); i++)
{
int to = g[v][i];
for (int diam = 0; diam <= max_diam[v]; diam++)
for (int de = 0; de <= max_depth[v]; de++)
{
dp[i + 1][diam][de] += dp[i][diam][de];
if (to == p)
continue;
for (int cdiam = 0; cdiam <= max_diam[to]; cdiam++)
for (int cde = 0; cde <= max_depth[to]; cde++) {
int ndiam = max(max(cdiam, diam), cde + 1 + de);
int nde = max(cde + 1, de);
dp[i + 1][ndiam][nde] += dp[i][diam][de] * ans[to][cdiam][cde];
}
}
if (to != p) {
if (max_depth1 < max_depth[to] + 1) {
max_depth2 = max_depth1;
max_depth1 = max_depth[to] + 1;
} else if (max_depth2 < max_depth[to] + 1)
max_depth2 = max_depth[to] + 1;
max_diam[v] = max_depth1 + max_depth2;
max_depth[v] = max_depth1;
}
}
for (int diam = 0; diam <= max_diam[v]; diam++)
for (int de = 0; de <= max_depth[v]; de++) {
ans[v][diam][de] = dp[sz(g[v])][diam][de];
if (diam <= k)
res += ans[v][diam][de];
}
}
int main() {
int t; scanf("%d", &t);
while (t--) {
scanf("%d %d", &n, &k);
forn(i, n)
g[i].clear();
forn(i, n - 1) {
int a, b; scanf("%d %d", &a, &b);
g[a].pb(b); g[b].pb(a);
}
res = 0;
dfs(0);
printf("%I64d\n", res);
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxtYXRoLmg+CiNpbmNsdWRlIDxjc3RkbGliPgojaW5jbHVkZSA8bWVtb3J5Lmg+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVkZSA8Y21hdGg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBmIGZpcnN0CiNkZWZpbmUgcyBzZWNvbmQKI2RlZmluZSBtcCBtYWtlX3BhaXIgCiNkZWZpbmUgc3ooQSkgKChpbnQpKEEpLnNpemUoKSkKI2RlZmluZSBmb3JuKGksIG4pIGZvciAoaW50IGkgPSAwOyBpIDwgaW50KG4pOyBpKyspCiNkZWZpbmUgZm9yZChpLCBuKSBmb3IgKGludCBpID0gaW50KG4pIC0gMTsgaSA+PSAwOyBpLS0pCiNkZWZpbmUgZm9yYW4oaSwgYSwgbikgZm9yIChpbnQgaSA9IGludChhKTsgaSA8IGludChuKTsgaSsrKQojZGVmaW5lIHkxIGdmdHhkdHJ0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