#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e4+5,INF=1e9;
int read(){
char c=getchar();int x=0,f=1;
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1; c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘; c=getchar();}
return x*f;
}
int n,u,v,w;
struct edge{
int v,w,ne;
}e[N<<1];
int h[N],cnt;
inline void ins(int u,int v,int w){
cnt++;
e[cnt].v=v;e[cnt].w=w;e[cnt].ne=h[u];h[u]=cnt;
cnt++;
e[cnt].v=u;e[cnt].w=w;e[cnt].ne=h[v];h[v]=cnt;
}
int size[N],f[N],rt,vis[N],sum;
void dfsRt(int u,int fa){
size[u]=1;f[u]=0;
for(int i=h[u];i;i=e[i].ne){
int v=e[i].v;
if(vis[v]||v==fa) continue;
dfsRt(v,u);
size[u]+=size[v];
f[u]=max(f[u],size[v]);
}
f[u]=max(f[u],sum-size[u]);
if(f[u]<f[rt]) rt=u;
}
int deep[N],cou[4];
void dfsDeep(int u,int fa){
cou[deep[u]]++;
for(int i=h[u];i;i=e[i].ne){
int v=e[i].v;
if(vis[v]||v==fa) continue;
deep[v]=(deep[u]+e[i].w)%3;
dfsDeep(v,u);
}
}
int cal(int u,int now){
deep[u]=now%3;
memset(cou,0,sizeof(cou));
dfsDeep(u,0);
return cou[0]*cou[0]+cou[1]*cou[2]*2;
}
int ans;
void dfsSol(int u){//printf("sol %d\n",u);
vis[u]=1;
ans+=cal(u,0);
for(int i=h[u];i;i=e[i].ne){
int v=e[i].v;
if(vis[v]) continue;
ans-=cal(v,e[i].w);
sum=size[v];
rt=0;dfsRt(v,0);v=rt;
dfsSol(v);
}
}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main(){
//freopen("in.txt","r",stdin);
n=read();
for(int i=1;i<n;i++) u=read(),v=read(),w=read(),ins(u,v,w);
sum=n;
f[0]=INF;
rt=0;dfsRt(1,0);
dfsSol(rt);
int g=gcd(ans,n*n);
printf("%d/%d",ans/g,n*n/g);
}