#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
#define INF (1ll<<58)

	
int main(){
	long long n,m;
	while(cin >> n >> m && n){
		long long land[200][200] , ship[200][200] ;
		rep(i,200)rep(j,200)land[i][j] = ship[i][j] = INF;
		rep(i,200)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			string l;
			long long a,b,c; cin >> a >> b >> c >> l;
			a--,b--;
			if(l=="L")land[a][b] = land[b][a] = min(c,land[a][b]);
			else      ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		long long r; cin >> r;
		long long R[1000];	
		rep(i,r)cin >> R[i] , R[i]--;
		
		long long dp[2][200];
		rep(j,2)rep(k,200)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					long long newCost = dp[bit%2][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[(bit+1)%2][next] = min( dp[(bit+1)%2][next],newCost);
				}
				dp[(bit+1)%2][cur] = min(dp[(bit+1)%2][cur],dp[bit%2][cur]+land[R[bit]][R[bit+1]]);
			}
			rep(j,200)dp[bit%2][j] = INF;
		}
		long long ret = INF;
		rep(i,n){
			ret = min(dp[(r-1)%2][i],ret);
		}
		cout << ret << endl;
		
	}
}