#include<bits/stdc++.h>usingnamespacestd;constintinf=1e7;voidsolve(){intn,m,k;cin>>n>>m>>k;vector<vector<pair<int,int>>>adj(n);for(inti=0;i<m;i++){intu,v,w;cin>>u>>v>>w;u--;v--;adj[u].push_back(make_pair(v,w));adj[v].push_back(make_pair(u,w));}vector<bool>has_switch(n,false);for(inti=0;i<k;i++){intindex;cin>>index;index--;has_switch[index]=true;}// Each vertex in state graph is identified by (vertex, flip_cnt%2)
vector<vector<int>>level(n,vector<int>(2,inf));queue<pair<int,int>>bfs;level[0][0]=0;bfs.push(make_pair(0,0));if(has_switch[0]){level[0][1]=0;bfs.push(make_pair(0,1));}while(!bfs.empty()){intvertex_now=bfs.front().first;intflip_cnt=bfs.front().second;intdist_now=level[vertex_now][flip_cnt];bfs.pop();for(autochild:adj[vertex_now]){// Don't use the switch. In that case, an edge would only be
// iterable if the the xor of flip_cnt and edge weight is 1.
if(child.second^flip_cnt==1){intnxt=child.first;// Don't use the switch.
if(level[nxt][flip_cnt]==inf){level[nxt][flip_cnt]=dist_now+1;bfs.push(make_pair(nxt,flip_cnt));}}// Now, use the switch at this vertex if possible.
if(child.second^flip_cnt==0){intnxt=child.first;// Use the switch.
if(has_switch[vertex_now]&&level[nxt][flip_cnt^1]==inf){level[nxt][flip_cnt^1]=dist_now+1;bfs.push(make_pair(nxt,flip_cnt^1));}}}}intres=min(level[n-1][0],level[n-1][1]);if(res>=inf){cout<<-1<<endl;}else{cout<<res<<endl;}}intmain(){solve();return0;}