program gpaths;

const
	MAXN					= 100000;     { 100000 }
	INF					= 1000000000; { 1000000000 }

type
	Integer					= LongInt;
	PNode					= ^TNode;
	TNode					= record
		d, l				: Integer;
		next				: PNode;
	end;
	TClosest				= record
		d, l				: Integer;
		d1, l1				: Integer;
	end;

var
	G					: Array [1 .. MAXN] of PNode;
	L					: Array [1 .. MAXN] of PNode;
	used					: Array [1 .. MAXN] of Boolean;
	isgc					: Array [1 .. MAXN] of Integer;
	dpar, par				: Array [1 .. MAXN] of Integer;
	res					: Array [1 .. MAXN] of TClosest;
	N, K					: Integer;
	i, a, b, c, pc				: Integer;
	P					: Pointer;

procedure add(x, y, c: Integer);
begin
	if (G[x] = NIL) then begin
		new(G[x]);
		G[x]^.d := y;
		G[x]^.l := c;
		G[x]^.next := NIL;
		L[x] := G[x];
	end else begin
		new(L[x]^.next);
		L[x]^.next^.d := y;
		L[x]^.next^.l := c;
		L[x]^.next^.next := NIL;
		L[x] := L[x]^.next;
	end;
end;

procedure readInput;
begin
	readln(N, K);
	for i := 1 to N do begin
		isgc[i] := 0;
		G[i] := NIL;
	end;
	for i := 1 to (N-1) do begin
		readln(a, b, c);
		add(a, b, c);
		add(b, a, c);
	end;
	for i := 1 to K do begin
		readln(a);
		isgc[a] := i;
	end;
end;

procedure dfs(c: Integer);
var
	i					: PNode;
begin
	i := G[c];
	used[c] := True;
	while (i <> NIL) do begin
		if (not used[i^.d]) then begin
			dpar[i^.d] := i^.l;
			par[i^.d] := c;
			dfs(i^.d);
			if (isgc[i^.d]>0) then begin
				if ((i^.l < res[c].l) or
				((i^.l = res[c].l) and (isgc[i^.d] < res[c].d))) then begin
					res[c].d1 := res[c].d;
					res[c].l1 := res[c].l;
					res[c].d := isgc[i^.d];
					res[c].l := i^.l;
				end else if ((i^.l < res[c].l1) or
				((i^.l = res[c].l1) and (isgc[i^.d] < res[c].d1))) then begin
					res[c].d1 := isgc[i^.d];
					res[c].l1 := i^.l;
				end;
			end;
			if ((res[i^.d].l+i^.l< res[c].l) or
			((res[i^.d].l+i^.l = res[c].l) and (res[i^.d].d < res[c].d))) then begin
				res[c].d1 := res[c].d;
				res[c].l1 := res[c].l;
				res[c].d := res[i^.d].d;
				res[c].l := res[i^.d].l + i^.l;
				if ((res[i^.d].l1 + i^.l < res[c].l1) or
				((res[i^.d].l1 + i^.l = res[c].l1) and (res[i^.d].d1 < res[c].d1))) then begin
					res[c].l1 := res[i^.d].l1 + i^.l;
					res[c].d1 := res[i^.d].d1;
				end;
			end else if ((res[i^.d].l + i^.l < res[c].l1) or
			((res[i^.d].l + i^.l = res[c].l1) and (res[i^.d].d < res[c].d1))) then begin
				res[c].d1 := res[i^.d].d;
				res[c].l1 := res[i^.d].l + i^.l;
			end;
		end;
                i := i^.next;
	end;
end;

procedure dfs2(c: Integer);
var
	i					: PNode;
begin
  used[c] := True;
  if (par[c] > 0) then begin
	pc:=par[c];
	if (isgc[c] <> res[pc].d) then begin
		if (res[pc].l+dpar[c]<res[c].l) or ((res[pc].l+dpar[c]=res[c].l)and (res[pc].d<res[c].d))then
		begin
			res[c].l1 := res[c].l;
			res[c].d1 := res[c].d;
		    	res[c].l := res[pc].l+dpar[c];
		    	res[c].d := res[pc].d;
			if (res[pc].l1+dpar[c]<res[c].l1)or ((res[pc].l1+dpar[c]=res[c].l1)and (res[pc].d1<res[c].d1))then
			begin
				res[c].l1 := res[pc].l1+dpar[c];
				res[c].d1:=res[pc].d1;
			end;
		end else
		if(res[pc].l+dpar[c]<res[c].l1) or ((res[pc].l+dpar[c]=res[c].l1)and (res[pc].d<res[c].d1)) then begin
		    	res[c].l1 := res[pc].l+dpar[c];
		    	res[c].d1 := res[pc].d;
		end;
		
	end
	else if (isgc[c] <> res[par[c]].d1) then begin
		if (res[pc].l1+dpar[c]<res[c].l1)or ((res[pc].l1+dpar[c]=res[c].l1)and (res[pc].d1<res[c].d1))then
		begin
			res[c].l1 := res[pc].l1+dpar[c];
			res[c].d1:=res[pc].d1;
		end;
	end;
  end;
	i := G[c];
	while (i <> NIL) do begin
        	if (not used[i^.d]) then
			dfs2(i^.d);
		i := i^.next;
	end;
end;

procedure Solve;
begin
	for i := 1 to N do begin
		res[i].l := INF;
		res[i].l1 := INF;
		used[i] := False;
	end;
	par[1] := 0;
	dfs(1);
	for i := 1 to N do
		used[i] := False;
	dfs2(1);
end;

procedure writeOutput;
begin
	for i := 1 to N do
		if (res[i].l = INF) then begin
			res[i].l := res[par[i]].l +dpar[i];
			res[i].d:=res[par[i]].d;
		end else
			writeln(res[i].d, ' ', res[i].l);
end;

begin
	Mark(P);
	readInput;
	Solve;
	writeOutput;
	Release(P);
end.
	