#include <stdio.h>
#define MAXX (long long) 100000001
long n,k;
long a[100001][500];
long long best;
long long cur,i0;
long b[100001];
long used[100001];
void init()
{
long kk,i,j,c;
scanf("%ld %ld",&n,&k);
for (kk=1;kk<n;kk++)
  {
   scanf("%ld %ld %ld",&i,&j,&c);
   a[i][0]++;
   a[i][2*a[i][0]-1]=j;
   a[i][2*a[i][0]]=c;
   a[j][0]++;
   a[j][2*a[j][0]-1]=i;
   a[j][2*a[j][0]]=c;
   }
for (kk=1;kk<=k;kk++)
 {

  scanf("%ld",&j);
  b[j]=kk;
  }

}
void DFS(int l)
{
long z,i;
 used[l]=1;
 for (i=1;i<=a[l][0];i++)
  {
   z=a[l][2*i-1];
   if (used[z]==0)
      if (b[z])
        {if (cur+a[l][2*i]<best)
        {
            i0=z;
            best=cur+a[l][2*i];


        }}
        else
        {

         cur+=a[l][2*i];
         DFS(z);
         cur-=a[l][2*i];
        }
   }

}
/*
void DFS(long l,long r)
{
long i,z;
if (l==r)
  return;
for (i=1;i<=a[l][0];i++)
  {
  z=a[l][2*i-1];
  if (r!=z)
    {
      if (b[z])
        if (cur+a[l][2*i]<best)
         {
           i0=z;
           best=cur+a[l][2*i];
           DFS(i,i);
           }
         else return;

       else {
        cur+=a[l][2*i];
         if (cur<best)
            DFS(a[l][2*i-1],l);
         cur-=a[l][2*i];
            }
     }
    else return;
    }

}
*/

int main()
{
long i;

//*a=(long *)malloc((n+2)*sizeof(long));
//  for (i=1;i<=n;i++)
// a[i]=(long *)malloc((n+2)*sizeof(long));
init();
for (i=1;i<=n;i++)
  {
   long j;
   for (j=1;j<=n;j++)
   used[j]=0;
   best=MAXX;
   cur=0;
   DFS(i);
   printf("%ld %ld\n",b[i0],best);
   }

return 0;
}
