#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[200][200],b[200][200],c[1000],d[1000][200],n,m,l;
int fn(int p,int q){
  int i;
  if(p+1==l)
    return 0;
  if(d[p][q])
    return d[p][q];
  int mn=a[c[p]][c[p+1]]+fn(p+1,q);
  for(i=0;i<n;++i){
    if(i!=q&&b[q][i]!=(1<<29))
      mn=min(mn,a[c[p]][q]+b[q][i]+a[i][c[p+1]]+fn(p+1,i));
  }
  return d[p][q]=mn;
}
int main(){
  int i,j,k;
  while(scanf("%d%d",&n,&m),n||m){
    fill(a[0],a[0]+200*200,1<<29);
    fill(b[0],b[0]+200*200,1<<29);
    for(i=0;i<n;++i)
      a[i][i]=b[i][i]=0;
    for(i=0;i<m;++i){
      int p,q,r;
      char s;
      scanf("%d%d%d %c",&p,&q,&r,&s);
      --p;
      --q;
      if(s=='L'){
	if(a[p][q]>r)
	  a[p][q]=a[q][p]=r;
      }else{
	if(b[p][q]>r)
	  b[p][q]=b[q][p]=r;
      }
    }
    for(k=0;k<n;++k){
      for(i=0;i<n;++i){
	for(j=0;j<n;++j){
	  a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	  b[i][j]=min(b[i][j],b[i][k]+b[k][j]);
	}
      }
    }
    scanf("%d",&l);
    for(i=0;i<l;++i){
      scanf("%d",c+i);
      --c[i];
    }
    memset(d,0,sizeof(d));
    printf("%d\n",fn(0,c[0]));
  }
  return 0;
}