#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;
}
int visited[maxn], res, a[maxn], hei, val, n, u[maxn], v[maxn], pos, cnt, quali, res1[maxn], res2[maxn], posmx1[maxn], posmx2[maxn];
vii g[maxn], h[maxn];
void dfs1(int s, int tmph, int pa = -1){
visited[s] = 1;
if (tmph > hei){
hei = tmph;
pos = s;
}
for (int tmp : h[s]){
if (tmp == pa) continue;
dfs1(tmp, tmph + 1, s);
}
}
void finddk(int s, int tmph, int pa = -1){
res = max(res, tmph);
for (int tmp : h[s]){
if (tmp == pa) continue;
finddk(tmp, tmph + 1, s);
}
}
void pre(int s, int pa){
for (int tmp : g[s]){
if (tmp == pa) continue;
pre(tmp, s);
if (a[tmp] == 1){
if (res1[tmp] + 1 > res1[s]){
res2[s] = res1[s];
posmx2[s] = posmx1[s];
res1[s] = res1[tmp] + 1;
posmx1[s] = tmp;
}
else if (res1[tmp] + 1 > res2[s]){
res2[s] = res1[tmp] + 1;
posmx2[s] = tmp;
}
}
}
}
void dfs(int s, int pa, int mx){
if (a[s] == 2){
if (max(mx, res2[s]) == res && res1[s] == res) quali = 1;
}
for (int tmp : g[s]){
if (tmp == pa) continue;
if (a[s] == 1){
if (tmp != posmx1[s]) dfs(tmp, s, max(mx, res1[s]) + 1);
else dfs(tmp, s, max(mx, res2[s]) + 1);
}
else dfs(tmp, s, 0);
}
}
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 = inf;
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);
finddk(pos, 1);
}
}
quali = 0;
pre(1, 0);
dfs(1, 0, 0);
if (quali){
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();
}