#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define N 20010
using namespace std;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
return x*f;
}
struct edge{int to,next,v;}e[2*N];
int head[N],son[N],f[N],d[N],tot[3];
int n,cnt,sum,root,ans;
bool vis[N];
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline void ins(int u,int v,int w)
{
e[++cnt].to=v;
e[cnt].v=w;
e[cnt].next=head[u];
head[u]=cnt;
}
inline void insert(int u,int v,int w)
{
ins(u,v,w);
ins(v,u,w);
}
inline void getroot(int x,int fa)
{
son[x]=1;f[x]=0;
for (int i=head[x];i;i=e[i].next)
if (!vis[e[i].to]&&fa!=e[i].to)
{
getroot(e[i].to,x);
son[x]+=son[e[i].to];
f[x]=max(f[x],son[e[i].to]);
}
f[x]=max(f[x],sum-son[x]);
if (f[x]<f[root])root=x;
}
inline void getd(int x,int fa)
{
tot[d[x]%3]++;
for (int i=head[x];i;i=e[i].next)
if(!vis[e[i].to]&&fa!=e[i].to)
{
d[e[i].to]=d[x]+e[i].v;
getd(e[i].to,x);
}
}
inline int calc(int x,int v)
{
d[x]=v;tot[0]=tot[1]=tot[2]=0;
getd(x,0);
return tot[0]*(tot[0]-1)/2+tot[1]*tot[2];
}
inline void solve(int x)
{
ans+=calc(x,0);vis[x]=1;
for(int i=head[x];i;i=e[i].next)
if (!vis[e[i].to])
{
ans-=calc(e[i].to,e[i].v);
sum=son[e[i].to];
root=0;
getroot(e[i].to,0);
solve(root);
}
}
int main()
{
n=read();
for (int i=1;i<n;i++)
{
int x=read(),y=read(),z=read()%3;
insert(x,y,z);
}
f[0]=n+1;sum=n;
getroot(1,0);
solve(root);
ans=ans*2+n;
int des=gcd(ans,n*n);
printf("%d/%d\n",ans/des,n*n/des);
return 0;
}