#include<stdio.h>
#include<vector>
#include<map>
#include<set>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 222222
map<pair<int,int>,long long>hash;
set<pair<long long, pair<int,int> > >pQ;
set<int>S;
char dump[1025];
int n,m,k,i,j,x,y,repaint[maxn],ax[maxn],ay[maxn],color[maxn],z;
long long he,dst,ans[maxn];
vector<pair<int,int> >v[maxn];
void push(int x,int y,long long z){
if(x==y)return;
if(hash.count(make_pair(x,y))&&hash[make_pair(x,y)]<=z)return;
if(hash.count(make_pair(x,y))){
he=hash[make_pair(x,y)];
if(pQ.find(make_pair(he,make_pair(x,y)))!=pQ.end())pQ.erase(pQ.find(make_pair(he,make_pair(x,y))));
}
hash[make_pair(x,y)]=z;
pQ.insert(make_pair(z,make_pair(x,y)));
}
void give(long long k,int x,int y,int l,int r){
set<int>::iterator it;
while(1){
it=S.lower_bound(l);
if(it==S.end())return;
if(*it>r)return;
ans[*it]=k;ax[*it]=x;ay[*it]=y;
S.erase(it);
}
}
int main(){
freopen("parties.in","r",stdin);
freopen("parties.out","w",stdout);
scanf("%d%d%d",&n,&m,&k);gets(dump);
for(i=1;i<=n;i++)color[i]=(getchar()=='L');
for(i=1;i<=m;i++){
scanf("%d%d%d",&x,&y,&z);
v[x].push_back(make_pair(z,y));
v[y].push_back(make_pair(z,x));
push(min(x,y),max(x,y),z);
}
for(i=1;i<=n;i++)repaint[i]=n+1;
for(i=1;i<=k;i++){
scanf("%d",&x);
repaint[x]=i;
}
for(i=0;i<=k;i++)S.insert(i);
while(pQ.size()&&S.size()){
dst=pQ.begin()->first;x=pQ.begin()->second.first;y=pQ.begin()->second.second;pQ.erase(pQ.begin());
if(color[x]==color[y]){
give(dst,x,y,0,min(repaint[x],repaint[y])-1);
give(dst,x,y,max(repaint[x],repaint[y]),n);
}else give(dst,x,y,min(repaint[x],repaint[y]),max(repaint[x],repaint[y])-1);
// if(color[x]!=color[y]){
for(i=0;i<v[x].size();i++)push(v[x][i].second,y,dst+v[x][i].first);
for(i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