const MAXST = 5000;
type OGR1 = 1..MAXST;
     OGR2 = 2..MAXST;
     OGR3 = 3..MAXST;
     DataT = record
       d: array [1..MAXST] of byte;
     end;
     Matrix = array [1..100,1..100] of byte;
     Stack = record
       Elem : array [1..MAXST] of OGR1;
       br : integer;
     end;
var Put : DataT;
    s : Stack;
    mat : Matrix;
    index,max,a,b,c,l,i,j,g : OGR1;
    k : OGR2;
    n : OGR3;
    zala : array [1..5000] of byte;
Procedure Push (var s : stack; num : integer);
begin
  With s do begin
    inc(br);
    Elem[br]:=num;
  end;
end;
Procedure Pop (var s : stack);
begin
  With s do begin
    dec(br);
  end;
end;
Procedure DFS (FElem : integer; mat : Matrix;var s : stack);
  var i,j,g,x:integer;
begin
  With s do begin
  br:=0;
  Push(s,FElem);
    for i:= 1 to n do
      for j:= 1 to n do begin
        if mat[Elem[i],j] <> 0 then Push(s,j);
        x:=Elem[br];
        for g:= 1 to (br-1) do
          if Elem[g]=x then Pop(s);
      end;
  end;
end;
begin
  readln(N,K);
  fillchar(mat,SizeOf(mat),0);
  for i:= 1 to (n-1) do begin
    readln(a,b,c);
    mat[a,b]:=c;
    mat[b,a]:=c;
  end;
  for i:= 1 to k do
    readln(zala[i]);
  for i:= 1 to n do begin
    fillchar(Put.d,SizeOf(Put.d),255);
    DFS(i,mat,s);
    Put.d[s.Elem[1]]:=0;
    for l:= 1 to n do begin
      for j:= 1 to n do begin
        if (mat[s.Elem[l],j] > 0) and (Put.d[j] > Put.d[s.Elem[l]]+mat[s.Elem[l],j]) then
          Put.d[j]:=Put.d[s.Elem[l]]+mat[s.Elem[l],j];
      end;
    end;
    if Put.d[zala[1]]>0 then begin max:=Put.d[zala[1]]; index:=1; end
                        else begin max:=Put.d[zala[2]]; index:=2; end;

    for g:= 2 to k do
      if (Put.d[zala[g]]<max) and (Put.d[zala[g]]>0) then begin index:=g; max:=Put.d[zala[g]]; end;
    writeln(index,' ',max);
  end;
end.