using namespace std;
long nrt[301][301];
int n,s;
int ifvisit[301];
int nrtd[301];
long lookford;
int lookfordu;
long fplenth;
int dlast;
int lookfordif;
int dpath[301];
int dpathh(int pnumber)
{
for(int i=1;i<=pnumber;i++)dpath[i]=nrtd[i];
}
int dfs(int p,int lenth,int pnumber)
{
int i;
ifvisit[p]=1;
if(lookfordif==1){nrtd[pnumber]=p;cout<<5;}
if(lookfordif==0&&lenth>lookford){lookford=lenth;lookfordu=p;cout<<4;}
if(lookfordif==1&&lenth>=lookford){dlast=pnumber;dpathh(pnumber);cout<<5;}
if(lookfordif==2&&lenth>fplenth){fplenth=lenth;cout<<6;}
for(i=1;i<=n;i++)
if(ifvisit[i]==0&&nrt[p][i]>0){dfs(i,lenth+nrt[p][i],pnumber+1);}
}
int huntecc(int s)
{
int i,j,k,l;long flen=0;long maxecc=999999999,minecc=99999999;lookfordif=2;
for(i=dlast+1;i<=n;i++)dpath[i]=0;
for(i=1;i<=dlast;i++)
{
for(l=1;l<=dlast-l+1;l++)
{ flen=0;
if(i==1);
else for(k=l+1;k<=l+i-1;k++)
flen+=nrt[dpath[k-1]][dpath[k]];
if(flen<=s)
{
maxecc=0;
memset(ifvisit,0,sizeof(ifvisit));
for(j=l;j<=l+i-1;j++)
{ fplenth=0;
ifvisit[dpath[j]]=0;
if(i!=1&&j!=l+i-1)ifvisit[dpath[j+1]]=1;
dfs(j,0,1);
ifvisit[dpath[j]]=1;
if(fplenth>maxecc)maxecc=fplenth;
}
}
if(minecc>maxecc)minecc=maxecc;
}
}
cout<<minecc<<endl;
}
int main()
{
int i,j,k;
cin>>n>>s;
for(i=1;i<n;i++)
{cin>>j>>k;cin>>nrt[j][k];nrt[k][j]=nrt[j][k];}
dfs(1,0,1);
cout<<1;
lookfordif=1;
cout<<endl<<lookfordu<<endl;
memset(ifvisit,0,sizeof(ifvisit));
dfs(lookfordu,0,1);
cout<<endl;
for(i=1;i<=dlast;i++)cout<<dpath[i];
cout<<endl;
cout<<2;
huntecc(s);
cout<<3;
return 0;
}