//简单题,先用弗洛伊德算法求各个点最短路径,
每个点到其他点选取最大值,为最后传播的时间,
在求出其中最小的为开始散播的人速度最快的
#include<iostream>
#include<cstring>
#define MAX 100
#define INF 100000
using namespace std;
int map[MAX][MAX];
int n;
int main()
{
int i,j,k;
int num;
int con,time;
while(cin>>n,n)
{
memset(map,0,sizeof(map));
for(i=1; i<=n; i++)
{
cin>>num;
while(num--)
{
cin>>con>>time;
map[i][con]=time;
}
}
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(i==j)map[i][j]=0;
else if(map[i][j]==0)map[i][j]=INF;
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(map[i][j]>map[i][k]+map[k][j])
map[i][j]=map[i][k]+map[k][j];
}
int maxtemp;
int maxt=INF;
int sp=1;
for(i=1; i<=n; i++)
{
maxtemp=map[i][1];
for(j=2; j<=n; j++)
{
if(map[i][j]>maxtemp)
{
maxtemp=map[i][j];
}
}
if(maxt>maxtemp)
{ maxt=maxtemp,sp=i;}
}
if(maxt>=INF) cout<<"disjoint"<<endl;
else cout<<sp<<" "<<maxt<<endl;
}
return 0;
}