var a:array[1..1000,1..1000] of longint;
    kk:array[1..1000] of longint;
    minp,cc:longint;
    k,n,i,j:longint;
procedure inp;
var i,p,l:longint;
begin
  read(n);
  readln(k);
  for i:=1 to n-1 do begin
                       read(p);
                       read(l);
                       read(a[p][l]);
                       a[l][p]:=a[p][l];
                     end;
  for i:=1 to k do readln(kk[i]);
end;
function club(p:longint):boolean;
var i:longint;
begin
  club:=false;
  for i:=1 to k do if (kk[i]=p) then club:=true;
end;
procedure init;
var i,j:longint;
begin
  for i:=1 to n do
      for j:=1 to n do a[i][j]:=-1;
end;
procedure track(e:longint;p:longint);
var i,c:longint;
begin
  if (p>minp) then exit;
  if (club(e) and (p>0) and (minp>p)) then begin
                                             minp:=p;
                                             cc:=e;
                                             exit;
                                           end;
  for i:=1 to n do begin
                     if (a[e][i]>0) then begin
                                    c:=a[e][i];
                                    a[e][i]:=-1;
                                    a[i][e]:=-1;
                                    track(i,p+c);
                                    a[e][i]:=c;
                                    a[i][e]:=c;
                                    end;
                   end;
end;
begin
inp();
{minp:=10000000;}
for i:=1 to n do  begin
                   minp:=1000000;
                   track(i,0);
                   for j:=1 to k do if kk[j]=cc then begin
                                                       cc:=j;
                                                       break;
                                                     end;
                   writeln(cc,' ',minp);
                  end;
end.
