#include<iostream>
#include<algorithm>
#define N 1000000000
using namespace std;

int L[210][210],S[210][210];
int dp[1100][210];
int n,m;
int x,y,t;
char s;
int r,z[1100];

int main(){
  while(cin >> n >> m ,n||m){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	if(i==j){
	  L[i][j] = 0;
	  S[i][j] = 0;
	}else{
	  L[i][j] = N;
	  S[i][j] = N;
	}
      }
    }

    for(int i=0;i<m;i++){
      cin >> x >> y >> t >> s;
      if(s=='L'){
	L[x][y] = t;
	L[y][x] = t;
      }else{
	S[x][y] = t;
	S[y][x] = t;
      }
    }

    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  L[i][j] = min(L[i][j] , L[i][k] + L[k][j]);

    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  S[i][j] = min(S[i][j] , S[i][k] + S[k][j]);

    cin >> r;
    for(int i=0;i<r;i++)cin >> z[i];

    for(int i=0;i<r;i++){
      for(int j=1;j<=n;j++){
	dp[i][j] = N;
      }
    }
 
    dp[0][z[0]] = 0;

    for(int i=1;i<r;i++){
      for(int j=1;j<=n;j++){
	if(L[z[i-1]][z[i]] != N){
	  dp[i][j] = min(dp[i][j],dp[i-1][j] + L[z[i-1]][z[i]]);
	}
	for(int k=1;k<=n;k++){
	  if(S[j][k] != N && L[k][z[i]] !=N){
	    dp[i][k] = min(dp[i][k],dp[i-1][j] + L[z[i-1]][j] + S[j][k] + L[k][z[i]]);
	  }
	}
      }
    }
    int ans = N;
    for(int i=1;i<=n;i++)ans = min(ans,dp[r-1][i]);
    cout << ans << endl;
  }
}