program treepath; const MaxN=1000; MaxL=1000000000; type TLink = record next:longint; v,l:longint; end; var G: array[1..MaxN] of longint; GL:array[1..MaxN*2] of TLink; N:longint; v0,v1:integer; BT:array[1..MaxN] of word; L:array[1..MaxN] of longint; procedure ReadData; var i,j,k,m,d:longint; begin readln(N); for i:=1 to N do G[i]:=0; k:=0; for m:=1 to N-1 do begin readln(i,j,d); inc(k); with GL[k] do begin next:=G[i]; v:=j; l:=d end; G[i]:=k; inc(k); with GL[k] do begin next:=G[j]; v:=i; l:=d end; G[j]:=k; end; readln(v0,v1); end; procedure Gen(v:longint); var St:array[0..MaxN] of longint; Stc:longint; i,j,k,d:longint; begin Stc:=1; St[0]:=v; BT[v]:=0; L[v]:=0; while Stc>0 do begin dec(Stc); i:=St[Stc]; j:=G[i]; while j>0 do begin k:=GL[j].v; d:=GL[j].l; j:=GL[j].next; if k<>BT[i] then begin BT[k]:=i; L[k]:=L[i]+d; St[Stc]:=k; inc(Stc); end; end; end; end; procedure WriteResult; var i:word; begin writeln('L=',L[v1]); write(v1); i:=v1; repeat write(' <-(',L[i]-L[BT[i]],')- ',BT[i]); i:=BT[i]; until i=v0; writeln; end; begin ReadData; Gen(v0); WriteResult; end.