//最短路径算法,一开始结尾没有输出disjoined,WA...
#include<stdio.h>
#include<string.h>
#define Min(a, b) ((a)<(b) ? (a):(b))
#define Max(a, b) ((a)<(b) ? (b):(a))
#define INF 99999999
int n, d[101][101], weight[101][101];
void init()
{
int i, j, cnt, t, c;
memset(weight, 0, sizeof(weight));
for(i=1; i<=n; i++)
{
scanf("%d", &cnt);
for(j=0; j<cnt; j++)
{
scanf("%d%d", &t, &c);
weight[i][t] = c;
}
}
}
void sort()
{
int i, j, k;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(i==j)
d[i][j] = 0;
else
d[i][j] = INF;
}
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(weight[i][j])
d[i][j] = weight[i][j];
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(d[i][k]!=INF && d[k][j]!=INF)
d[i][j] = Min(d[i][j], d[i][k]+d[k][j]);
}
void output()
{
int max[101], rt = INF, i, j, p;
memset(max, 0, sizeof(max));
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(i != j)
{
max[i] = Max(max[i], d[i][j]);
}
for(i=1; i<=n; i++)
if(rt > max[i])
{
rt = max[i];
p = i;
}
if(rt == INF)
printf("disjoint/n");
else
printf("%d %d/n", p, rt);
}
/*void
output()
{
int i, j, p, rt, max[101];
memset(max, 0, sizeof(max));
rt = INF;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(i!=j)
{
max[i] = Max(max[i], d[i][j]);
}
for(i =1; i<=n; i++)
if(max[i] < rt)
{
rt = max[i];
p = i;
}
if(rt == INF)
printf("disjoint/n");
else
printf("%d %d/n", p, rt);
}
*/
int main()
{
while(scanf("%d", &n) && n)
{
init();
sort();
// printf("%d", n);
output();
}
return 0;
}