// cre: nnhzzz - Nguyen Ngoc Hung
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <unordered_set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>
#include <unordered_map>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll maxn = 1e5+7;
vector <int> G[105];
ll dp[105][maxn],pre[105][maxn],fre[105][maxn];
int n,m,p;
bool v[105];
void dfs(int u){
v[u] = 1;
for(int i = 1; i<=m; ++i){
dp[u][i] = 1;
}
for(int i = 0; i<(int)G[u].size(); ++i){
if(!v[G[u][i]]){
int v = G[u][i];
dfs(v);
for(int j = 1; j<=m; ++j){
if(p>0){
dp[u][j] = 1LL*dp[u][j]*(pre[v][max(j-p,0)]+fre[v][min(m+1,j+p)])%MOD;
}else{
dp[u][j] = 1LL*dp[u][j]*pre[v][m]%MOD;
}
}
}
}
for(int i = 1; i<=m; i++){
pre[u][i] = (pre[u][i-1]+dp[u][i])%MOD;
}
for(int i = m; i>0; i--){
fre[u][i] = (fre[u][i+1]+dp[u][i])%MOD;
}
v[u] = 0;
}
int main(){
#define name "test"
if(fopen(name".inp","r")){
freopen(name".inp","r",stdin);
freopen(name".out","w",stdout);
}
int t; cin >> t;
while(t--){
memset(G,0,sizeof(G));
memset(pre,0,sizeof(pre));
memset(fre,0,sizeof(fre));
cin >> n >> m >> p;
for(int i=1;i<n;++i){
int u,v; cin >> u >> v;
G[u].push_back(v);
G[v].push_back(u);
}
dfs(1);
cout << pre[1][m] << endl;
}
return 0;
}
Ly8gY3JlOiBubmh6enogLSBOZ3V5ZW4gTmdvYyBIdW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PSAxZTUrNzsKCnZlY3RvciA8aW50PiBHWzEwNV07CmxsIGRwWzEwNV1bbWF4bl0scHJlWzEwNV1bbWF4bl0sZnJlWzEwNV1bbWF4bl07CmludCBuLG0scDsKYm9vbCB2WzEwNV07Cgp2b2lkIGRmcyhpbnQgdSl7CiAgICB2W3VdID0gMTsKICAgIGZvcihpbnQgaSA9IDE7IGk8PW07ICsraSl7CiAgICAgICAgZHBbdV1baV0gPSAxOwogICAgfQogICAgZm9yKGludCBpID0gMDsgaTwoaW50KUdbdV0uc2l6ZSgpOyArK2kpewogICAgICAgIGlmKCF2W0dbdV1baV1dKXsKICAgICAgICAgICAgaW50IHYgPSBHW3VdW2ldOwogICAgICAgICAgICBkZnModik7CiAgICAgICAgICAgIGZvcihpbnQgaiA9IDE7IGo8PW07ICsrail7CiAgICAgICAgICAgICAgICBpZihwPjApewogICAgICAgICAgICAgICAgICAgIGRwW3VdW2pdID0gMUxMKmRwW3VdW2pdKihwcmVbdl1bbWF4KGotcCwwKV0rZnJlW3ZdW21pbihtKzEsaitwKV0pJU1PRDsKICAgICAgICAgICAgICAgIH1lbHNlewogICAgICAgICAgICAgICAgICAgIGRwW3VdW2pdID0gMUxMKmRwW3VdW2pdKnByZVt2XVttXSVNT0Q7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGkgPSAxOyBpPD1tOyBpKyspewogICAgICAgIHByZVt1XVtpXSA9IChwcmVbdV1baS0xXStkcFt1XVtpXSklTU9EOwogICAgfQogICAgZm9yKGludCBpID0gbTsgaT4wOyBpLS0pewogICAgICAgIGZyZVt1XVtpXSA9IChmcmVbdV1baSsxXStkcFt1XVtpXSklTU9EOwogICAgfQogICAgdlt1XSA9IDA7Cn0KCmludCBtYWluKCl7CiAgICAjZGVmaW5lIG5hbWUgInRlc3QiCiAgICBpZihmb3BlbihuYW1lIi5pbnAiLCJyIikpewogICAgICAgIGZyZW9wZW4obmFtZSIuaW5wIiwiciIsc3RkaW4pOwogICAgICAgIGZyZW9wZW4obmFtZSIub3V0IiwidyIsc3Rkb3V0KTsKICAgIH0KICAgIGludCB0OyBjaW4gPj4gdDsKICAgIHdoaWxlKHQtLSl7CiAgICAgICAgbWVtc2V0KEcsMCxzaXplb2YoRykpOwogICAgICAgIG1lbXNldChwcmUsMCxzaXplb2YocHJlKSk7CiAgICAgICAgbWVtc2V0KGZyZSwwLHNpemVvZihmcmUpKTsKICAgICAgICBjaW4gPj4gbiA+PiBtID4+IHA7CiAgICAgICAgZm9yKGludCBpPTE7aTxuOysraSl7CiAgICAgICAgICAgIGludCB1LHY7IGNpbiA+PiB1ID4+IHY7CiAgICAgICAgICAgIEdbdV0ucHVzaF9iYWNrKHYpOwogICAgICAgICAgICBHW3ZdLnB1c2hfYmFjayh1KTsKICAgICAgICB9CiAgICAgICAgZGZzKDEpOwogICAgICAgIGNvdXQgPDwgcHJlWzFdW21dIDw8IGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==