#include <bits/stdc++.h>
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define ForD(i, a, b) for (int i = (a); i >= (b); --i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repD(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define vi vector<int>
#define int long long
using namespace std;
void file(string s){
if (s.empty()) return;
freopen((s + ".inp").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int N = 70 + 5;
const int MOD = 1e9 + 7; //998244353;
int n, m, k, Pow[N], x[N], y[N], par[N];
vi g[N];
int up[N], h[N], Lca[N];
void add(int &x, int y){
x += y;
if (x >= MOD) x -= MOD;
if (x < 0) x += MOD;
}
int mul(int x, int y){
return x * y % MOD;
}
void dfs(int u){
for (int v: g[u]) if (v != up[u])
up[v] = u, h[v] = h[u] + 1, dfs(v);
}
int lca(int u, int v){
while (h[v] > h[u]) v = up[v];
while (u != v) u = up[u], v = up[v];
return u;
}
int find(int u){
return par[u] < 0 ? u : par[u] = find(par[u]);
}
void Union(int u, int v){
u = find(u); v = find(v);
if (u == v) return;
if (h[u] > h[v]) swap(u, v);
par[u] += par[v];
par[v] = u;
}
void add(int i){
int u = x[i], v = y[i];
while (h[u] > h[Lca[i]] + 1){
Union(u, up[u]);
u = up[u];
}
while (h[v] > h[Lca[i]] + 1){
Union(v, up[v]);
v = up[v];
}
if (u != Lca[i]) Union(u, v);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
file("coloring");
cin >> n >> m >> k;
rep(i, n - 1){
int u, v; cin >> u >> v;
g[u].pb(v); g[v].pb(u);
}
dfs(1);
rep(i, m){
cin >> x[i] >> y[i];
if (h[x[i]] > h[y[i]]) swap(x[i], y[i]);
if (x[i] == y[i]) return cout << 0, 0;
Lca[i] = lca(x[i], y[i]);
}
Pow[0] = 1;
For(i, 1, n - 1) Pow[i] = Pow[i - 1] * k % MOD;
int res = 0;
rep(msk, 1 << m){
memset(par, -1, sizeof par);
rep(i, m) if (msk & (1 << i))
add(i);
int cnt = 0;
For(i, 2, n) cnt += (par[i] < 0);
if (!(__builtin_popcount(msk) & 1))
add(res, Pow[cnt]);
else
add(res, -Pow[cnt]);
}
cout << res;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIEZvcihpLCBhLCBiKSBmb3IgKGludCBpID0gKGEpOyBpIDw9IChiKTsgKytpKQojZGVmaW5lIEZvckQoaSwgYSwgYikgZm9yIChpbnQgaSA9IChhKTsgaSA+PSAoYik7IC0taSkKI2RlZmluZSByZXAoaSwgbikgZm9yIChpbnQgaSA9IDA7IGkgPCAobik7ICsraSkKI2RlZmluZSByZXBEKGksIG4pIGZvciAoaW50IGkgPSAobikgLSAxOyBpID49IDA7IC0taSkKI2RlZmluZSBwYiBwdXNoX2JhY2sKCiNkZWZpbmUgdmkgdmVjdG9yPGludD4KCiNkZWZpbmUgaW50IGxvbmcgbG9uZwoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgZmlsZShzdHJpbmcgcyl7CgogICAgaWYgKHMuZW1wdHkoKSkgcmV0dXJuOwoKICAgIGZyZW9wZW4oKHMgKyAiLmlucCIpLmNfc3RyKCksICJyIiwgc3RkaW4pOwogICAgZnJlb3BlbigocyArICIub3V0IikuY19zdHIoKSwgInciLCBzdGRvdXQpOwp9Cgpjb25zdCBpbnQgTiA9IDcwICsgNTsKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7IC8vOTk4MjQ0MzUzOwoKaW50IG4sIG0sIGssIFBvd1tOXSwgeFtOXSwgeVtOXSwgcGFyW05dOwp2aSBnW05dOwppbnQgdXBbTl0sIGhbTl0sIExjYVtOXTsKCnZvaWQgYWRkKGludCAmeCwgaW50IHkpewogICAgeCArPSB5OwogICAgaWYgKHggPj0gTU9EKSB4IC09IE1PRDsKICAgIGlmICh4IDwgMCkgeCArPSBNT0Q7Cn0KCmludCBtdWwoaW50IHgsIGludCB5KXsKICAgIHJldHVyb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gPj4gazsKICAgIHJlcChpLCBuIC0gMSl7CiAgICAgICAgaW50IHUsIHY7IGNpbiA+PiB1ID4+IHY7CiAgICAgICAgZ1t1XS5wYih2KTsgZ1t2XS5wYih1KTsKICAgIH0KCiAgICBkZnMoMSk7CgogICAgcmVwKGksIG0pewogICAgICAgIGNpbiA+PiB4W2ldID4+IHlbaV07CiAgICAgICAgaWYgKGhbeFtpXV0gPiBoW3lbaV1dKSBzd2FwKHhbaV0sIHlbaV0pOwogICAgICAgIGlmICh4W2ldID09IHlbaV0pIHJldHVybiBjb3V0IDw8IDAsIDA7CiAgICAgICAgTGNhW2ldID0gbGNhKHhbaV0sIHlbaV0pOwogICAgfQoKICAgIFBvd1swXSA9IDE7CiAgICBGb3IoaSwgMSwgbiAtIDEpIFBvd1tpXSA9IFBvd1tpIC0gMV0gKiBrICUgTU9EOwoKICAgIGludCByZXMgPSAwOwogICAgcmVwKG1zaywgMSA8PCBtKXsKICAgICAgICBtZW1zZXQocGFyLCAtMSwgc2l6ZW9mIHBhcik7CiAgICAgICAgcmVwKGksIG0pIGlmIChtc2sgJiAoMSA8PCBpKSkKICAgICAgICAgICAgYWRkKGkpOwoKICAgICAgICBpbnQgY250ID0gMDsgCiAgICAgICAgRm9yKGksIDIsIG4pIGNudCArPSAocGFyW2ldIDwgMCk7CgogICAgICAgIGlmICghKF9fYnVpbHRpbl9wb3Bjb3VudChtc2spICYgMSkpCiAgICAgICAgICAgIGFkZChyZXMsIFBvd1tjbnRdKTsgCiAgICAgICAgZWxzZQogICAgICAgICAgICBhZGQocmVzLCAtUG93W2NudF0pOwogICAgfQoKICAgIGNvdXQgPDwgcmVzOyAgICAKCiAgICByZXR1cm4gMDsKfQo=