#include <iostream>
#include <stdio.h>
#include <string.h>
#define INF 0x7fffff
#define maxn 500 + 10
using namespace std;
int graph[maxn][maxn];
int vis[maxn];
int dis[maxn];
int n,k,m,a,b,cost;
bool falg;
int prim( int start,int num)
{
memset(vis,0,sizeof(vis));
memset(dis,INF,sizeof(dis));
for( int i = 1; i <= n; i++)
if(graph[start][i] != -1)
{
dis[i] = graph[start][i];
}
else
dis[i] = INF;
dis[start] = 0;
vis[start] = 1;
int sum = 0;
for( int i = 2; i<=n; i++)
{
int min = INF;
for( int j = 1; j<=n; j++)
if(vis[j] == 0 && min > dis[j])
{
min = dis[j];
k = j;
}
sum += dis[k];
vis[k] = 1;
for(int j =1; j<= n; j++)
{
if(vis[j] == 0 && graph[k][j] != -1 && dis[j] > graph[k][j] )
dis[j] = graph[k][j];
}
}
return sum;
}
int main()
{
while(scanf("%d",&n),n)
{
memset(graph,-1,sizeof(graph));
m = n*(n-1)/2;
for( int i =0 ;i <m; i++)
{
scanf("%d%d%d%d",&a, &b, &cost, &falg);
if(falg)
graph[a][b] = graph[b][a] = 0;
else
graph[a][b] = graph[b][a] = cost;
}
printf("%d/n",prim(1.n));
}
return 0;
}