#include <cstdio>
#include <vector>
#include <algorithm>
#define INT_MAX 100000

using namespace std;

int lmap[201][201],smap[201][201];
int dp[201][2];
vector<int> order;

int main(){
  int n,m,r,i,j,k;
  while(scanf("%d %d",&n,&m),n){
    order.clear();
    for(i=0;i<201;i++){
      for(j=0;j<201;j++)
	lmap[i][j]=smap[i][j]=INT_MAX;
      dp[i][0]=dp[i][1]=0;
    }

    for(i=0;i<m;i++){
      int x,y,t;
      char w;
      scanf("%d %d %d %c",&x,&y,&t,&w);
      if(w=='L')
	lmap[x][y]=lmap[y][x]=min(lmap[x][y],t);
      else
	smap[x][y]=smap[y][x]=min(smap[x][y],t);
    }
    
    scanf("%d",&r);
    for(i=0;i<r;i++){
      scanf("%d",&j);
      order.push_back(j);
    }

    for(i=1;i<=n;i++) lmap[i][i]=smap[i][i]=0;

    for(k=1;k<=n;k++)
      for(i=1;i<=n;i++)
	for(j=1;j<=n;j++){
	  lmap[i][j] = min(lmap[i][j],lmap[i][k]+lmap[k][j]);
	  smap[i][j] = min(smap[i][j],smap[i][k]+smap[k][j]);
	}
    
    for(i=r-2;i>=0;i--)
      for(j=1;j<=n;j++){
	int mint=INT_MAX;
	for(k=1;k<=n;k++){
	  int tmp;
	  if(k!=j)
	    tmp = dp[k][~i&1]+lmap[order[i+1]][k]+smap[k][j]+lmap[j][order[i]];
	  else
	    tmp = dp[k][~i&1]+lmap[order[i+1]][order[i]];
	  mint = min(mint,tmp);
	}
	dp[j][i&1] = mint;
      }

    printf("%d\n",dp[order[0]][0]);
  }
}