#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define AC "test"
#define foru(i, l, r) for (int i = (l); i <= (r); i++)
#define ford(i, l, r) for (int i = (l); i >= (r); i--)
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
const ll inf = 1e9 + 7;
const ll linf = 1e18 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const int base = 31;
void fastIO(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
ll mul(ll a, ll b){
a%=mod;
ll res = 0;
while (b){
if (b%2) res = (res + a)%mod;
a = (a + a)%mod;
b/=2;
}
return res;
}
ll Pow(ll a, ll b){
ll ans = 1;
while (b){
if (b % 2) ans = mul(ans, a);
a = mul(a, a);
b/=2;
}
return ans;
}
ll visited[maxn], res, a[maxn], hei, val, n, u[maxn], v[maxn], pos, mxh[maxn], par[maxn], quali;
vll g[maxn], h[maxn];
set<ll> setval;
void dfs1(int s, ll tmph, int root, int pa = -1){
visited[s] = 1;
if (tmph > hei){
hei = tmph;
pos = s;
}
par[s] = root;
for (int tmp : h[s]){
if (tmp == pa) continue;
dfs1(tmp, tmph + 1, root, s);
}
}
void finddk(int s, ll tmph, int pa = -1){
res = max(res, tmph);
hei = max(hei, tmph);
for (int tmp : h[s]){
if (tmp == pa) continue;
finddk(tmp, tmph + 1, s);
}
}
void inp(){
cin >> n;
foru(i, 1, n - 1){
cin >> u[i] >> v[i];
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
val = linf;
foru(i, 1, n){
cin >> a[i];
val = min(a[i], val);
}
}
void solve(){
foru(i, 1, n - 1){
if (a[u[i]] == 1 && a[v[i]] == 1){
h[u[i]].pb(v[i]);
h[v[i]].pb(u[i]);
}
}
foru(i, 1, n){
pos = 0;
hei = 0;
if (a[i] == 1 && !visited[i]){
dfs1(i, 1, i);
hei = 0;
finddk(pos, 1);
mxh[i] = hei;
}
}
quali = 0;
foru(i, 1, n){
if (a[i] == 2){
setval.clear();
for (int tmp : g[i]){
if (setval.find(2*res - mxh[par[tmp]]) != setval.end()) quali = 1;
setval.insert(mxh[par[tmp]]);
}
}
}
if (quali){
if (res % 2){
cout << "2/" << 2*res + 1;
}
}
else{
cout << "1/" << res;
}
}
int main(){
fastIO();
if (fopen(AC".inp", "r")){
freopen(AC".inp", "r", stdin);
freopen(AC".out", "w", stdout);
}
inp();
if (val != 1){
cout << val << "/1";
}
else solve();
}