#include <iostream.h>

long N, K;
const long MAXN = 100000;
typedef struct crossroad *crs;
typedef struct closest *close;
struct crossroad { long len, number; crs next; };
struct crossroad a[MAXN+1];
struct closest { long len, number; close next; };
struct closest b[MAXN+1];
struct { int exists; long number; } clubs[MAXN+1];

void add(crs a, long to, long from, long len) {
  crs tmp, t = NULL;
  t = &a[to];
  while (t->next != NULL) t = t-> next;
  t->next = new struct crossroad;
  tmp = t->next;
  tmp->next = NULL; tmp->len = len; tmp->number = from;
}

void add2(long to, long number, long len) {
  close tmp, t = NULL;
  t = &b[to];
  while (t->next != NULL)
    if (t->len < len && t->len != 0) return;
    else t = t->next;
  //cout << "adding club " << number << " to the list of clubs of " << to <<
  //  " with a length of " << len << endl;
  t->next = new struct closest;
  tmp = t->next;
  tmp->next = NULL; tmp->number = number; tmp->len = len;
}

void gen_clubs() {
  for (long i = 1; i <= N; i++)
    if (clubs[i].exists) {
      crs t = a[i].next;
      while (t != NULL) { add2(t->number,i,t->len); t = t->next; }
    }
}

void solve (long x, long long *zalaN, long long *dist, long orig) {
  close tmp, t = b[x].next;
  if (orig == -1) orig = x;
  //if (x != orig) cout << " -- " << x << " " << orig << endl;
  while (t != NULL)
    if (t->number != orig) { *zalaN = clubs[t->number].number; *dist = t->len; return; }
    else t = t->next;

  crs tmp1, t1 =a[x].next;
  long long min = MAXN*MAXN+1, zalaN_, dist_;

  while (t1 != NULL)
    if  (t1->number != orig) {
      solve(t1->number, &zalaN_, &dist_, x);
      if (dist_ + t1->len < min) {
        min = dist_ + t1->len; *zalaN = zalaN_; *dist = min;
      }
      t1 = t1->next;
    } else t1 = t1->next;

}

int main()
{
  long i;
  crs t = NULL;
  cin >> N >> K;

  long long tmp1, tmp2, tmp3;
  //for (i = 1; i <= N; i++) a[i].next = NULL;

  for (i = 1; i < N; i++)
    { long long tmp1, tmp2, tmp3;
      cin >> tmp1 >> tmp2 >> tmp3;
      add(a,tmp1,tmp2,tmp3); add(a,tmp2,tmp1,tmp3);
    }

  for (i = 1; i <= K; i++)
    { cin >> tmp1; clubs[tmp1].exists = 1; clubs[tmp1].number = i; }

  gen_clubs();
  for (i = 1; i<= N; i++)
    { solve(i,&tmp1,&tmp2,-1); cout << tmp1 << " " << tmp2 << endl; }

}
