var a:array[0..7000,0..7000]of longint;
    b:array[0..7000]of longint;
    n,k,i,x,y,c:longint;

Procedure Dixtra(i:longint);
var d:array[1..7000]of longint;
    j,h,min,l,fl:longint;
begin for j:=1 to n do
         begin if (a[i,j]<>0)and(i<>j)
                 then d[j]:=a[i,j]
                 else d[j]:=100001;
         end;
    repeat fl:=0;
        for j:=1 to n do
           for h:=1 to n do
              begin if (i<>j)and(j<>h)and(h<>i)and(d[h]<>100001)
                        then if a[j,h]<>0
                               then if d[j]>d[h]+a[j,h]
                                       then begin d[j]:=d[h]+a[j,h];
                                                  fl:=1;
                                            end;
              end;
    until fl=0;
        min:=100001;
        for j:=1 to k do
           if min>d[b[j]] then
                begin min:=d[b[j]];
                      l:=j;
                end;
        writeln(l,' ',min);
end;

begin  readln(n,k);
       for i:=1 to n-1 do
          begin readln(x,y,c);
                a[x,y]:=c;
                a[y,x]:=c;
          end;
       for i:=1 to k do
          readln(b[i]);
       for i:=1 to n do
          Dixtra(i);
end.

