#include <cstdio>
#include <cstdlib>

struct el {
    int to;
    int dist;
    el* next;
};
el *nlist[100001];
int indexh[100001];
struct hel {
    int num;
    int near;
    long long nearl;
};
struct ell {
        int to;
        long long dist;
};
hel heap [100001];
int zali[100001];
bool zala[100001];
ell dist[100001];

bool visited[100001];
int hp = 0;
void add_heap (int to, long long dist, int from) {
int pp;
     if (indexh[to] == -1) {
        int p = hp;

        while (p > 0) {
              pp = (p-1)/2;
              if (heap[pp].nearl > dist ||
                 heap[pp].nearl == dist && heap[pp].near > from) {
                 heap[p] = heap[pp];
                 p = pp;
              } else
                break;
        }
        heap[p].nearl = dist;
        heap[p].near = from;
        heap[p].num = to;
        indexh[to] = p;
        hp++;
      } else {
         if (heap[indexh[to]].nearl > dist ||
            (heap[indexh[to]].nearl == dist && heap[indexh[to]].near > from)) {

        int p = indexh[to];
        while (p > 0) {
              pp = (p-1)/2;
              if (heap[pp].nearl > dist ||
                 heap[pp].nearl == dist && heap[pp].near > from) {
                 heap[p] = heap[pp];
                 p = pp;
              } else
                break;
        }
        heap[p].nearl = dist;
        heap[p].near = from;
        heap[p].num = to;
        index[to] = p;
        hp++


        }
     }

}

hel pop_heap () {
    int p = 0;
    int pp = 2*p + 1;
    heap[hp] = heap[0];
    heap[0] = heap[--hp];
    hp--;
    if (pp+1 < hp && heap[pp].nearl < heap[hp].nearl || (heap[pp].nearl == heap[hp].nearl && heap[pp].near] < heap[hp].near)) {
          heap[p] = heap[pp];
          index[heap[p].num] = p;
    } else {
      if (heap[pp+1].nearl < heap[hp].nearl || (heap[pp+1].nearl == heap[hp].nearl && heap[pp+1].near] < heap[hp].near))
      
        heap[p] = heap[pp];
        index[heap[p]. num] = p;
    }

    heap[p] = heap[hp];
    return heap[hp+1];

}

void f () {
     el *tmp;
     for (int i = 0; i < K; ++i) {
        tmp = nlist[zali[i]];
        while (tmp != 0) {
              add_heap (tmp->to, tmp->dist, zali[i]);
              tmp = tmp->next;
        }
     }


     while (hp > 0) {
           hel crnt = pop_heap ();
           visited[crnt.near] = true;
           dist[crnt.near]->to = crnt.num;
           dist[crnt.near]->dist = crnt.dist;


           tmp = nlist[crnt.near];
           while (tmp != 0) {
               add_heap (tmp->to, tmp->dist + crnt.dist, crnt.num);
           }
     }
}



int main () {
    scanf ("%d%d", &N, &K);

    el *tmp;
    int x,y,z;
    for (int i = 1; i < N; ++i) {
        scanf ("%d%d%d", &x, &y, &z);
        tmp = new el;
        tmp-> to = y;
        tmp->dist = z;
        tmp->nxt = nlist[x];
        nlist[x]  = tmp;
        tmp = new el;
        tmp->to = x;
        tmp->dizt = z;
        tmp->next = nlist[y];
        nlist[y] = tmp;
    }
    for (int i = 1; i < K; ++i) {
        scanf ("%d", &x);
        zali[i] = x;
        zala[x] = true;
    }
}

