#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e16;
long long int MOD = 1000000007;

int main(){
	
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0){
			break;
		}
		long long int CL[300][300], CS[300][300];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				CL[i][j] = INF;
				CS[i][j] = INF;
			}
			CL[i][i] = 0;
			CS[i][i] = 0;
		}
		for(int i = 0; i < m; i++){
			long long int u, v, cost;
			cin >> u >> v >> cost;
			u--;
			v--;
			string str;
			cin >> str;
			if(str == "L"){
				cost = min(cost, CL[u][v]);
				CL[u][v] = cost;
				CL[v][u] = cost;
			}else{
				cost = min(cost, CS[u][v]);
				CS[u][v] = cost;
				CS[v][u] = cost;
			}
		}
		for(int k = 0; k < n; k++)
		for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++){
			CL[i][j] = min(CL[i][j], CL[i][k] + CL[k][j]);
			CS[i][j] = min(CS[i][j], CS[i][k] + CS[k][j]);
		}
		
		int R, pre, num;
		cin >> R;
		cin >> pre;
		pre--;
		
		long long int ans = INF, DP1[300], DP2[300];
		for(int i = 0; i < n; i++){
			DP1[i] = INF;
		}
		DP1[pre] = 0;
		for(int i = 1; i < R; i++){
			cin >> num;
			num--;
			for(int j = 0; j < n; j++){
				DP2[j] = DP1[j] + CL[pre][num];
				for(int k = 0; k < n; k++){
					DP2[j] = min(DP2[j], CL[pre][k] + DP1[k] + CS[k][j] + CL[j][num]);
				}
			}
			swap(DP1, DP2);
			pre = num;
		}
		
		for(int i = 0; i < n; i++){
			ans = min(ans, DP1[i]);
		}
		cout << ans << endl;
	}
	
	return 0;
}
