#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int parent[210],height[201];
int N,M;

struct Info{
	int shima_id;
	bool isMinato;
};

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;

	if(height[a_parent] > height[b_parent]){
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}

void init_array(){
	for(int i = 0; i < N; i++){
		parent[i] = i;
		height[i] = 0;
	}
}

void func(){

	Info info[N];
	for(int i = 0; i < N; i++)info[i].isMinato = false;

	int land_dist[N][N],sea_dist[N][N];

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(i != k){
				land_dist[i][k] = BIG_NUM;
				sea_dist[i][k] = BIG_NUM;
			}
			else{
				land_dist[i][k] = 0;
				sea_dist[i][k] = 0;
			}
		}
	}

	init_array();

	vector<int> MINATO[N];

	int from,to,time;
	char buf[2];

	for(int i = 0; i < M; i++){
		scanf("%d %d %d %s",&from,&to,&time,buf);
		from--;
		to--;

		if(buf[0] == 'L'){
			land_dist[from][to] = min(land_dist[from][to],time);
			land_dist[to][from] = min(land_dist[to][from],time);
			unite(from,to);
		}else{
			sea_dist[from][to] = min(sea_dist[from][to],time);
			sea_dist[to][from] = min(sea_dist[to][from],time);

			info[from].isMinato = true;
			info[to].isMinato = true;
		}
	}

	for(int a = 0; a < N; a++){
		for(int b = 0; b < N; b++){
			if(land_dist[b][a] == BIG_NUM)continue;
			for(int c = 0; c < N; c++){
				if(land_dist[a][c] == BIG_NUM)continue;
				land_dist[b][c] = min(land_dist[b][c],land_dist[b][a] + land_dist[a][c]);
			}
		}
	}

	for(int a = 0; a < N; a++){
		for(int b = 0; b < N; b++){
			if(sea_dist[b][a] == BIG_NUM)continue;
			for(int c = 0; c < N; c++){
				if(sea_dist[a][c] == BIG_NUM)continue;
				sea_dist[b][c] = min(sea_dist[b][c],sea_dist[b][a] + sea_dist[a][c]);
			}
		}
	}

	bool check[N];
	for(int i = 0; i < N; i++)check[i] = false;
	for(int i = 0; i < N; i++)check[getParent(i)]  = true;

	int shima_id = 0,table[N];

	for(int i = 0; i < N; i++){
		if(check[i]){
			table[i] = shima_id++;
		}
	}

	for(int i = 0; i < N; i++){
		info[i].shima_id = table[parent[i]];
		if(info[i].isMinato == true){
			MINATO[info[i].shima_id].push_back(i);
		}
	}

	int R;
	scanf("%d",&R);

	int sche[R];
	for(int i = 0; i < R; i++){
		scanf("%d",&sche[i]);
		sche[i]--;
	}

	int min_Cost[R][N];

	for(int i = 0; i < R; i++){
		for(int k = 0; k < N; k++){
			min_Cost[i][k] = BIG_NUM;
		}
	}

	min_Cost[0][sche[0]] = 0;

	int current_town,next_town,current_shima_id,next_shima_id,tmp,next_minato;

	for(int i = 0; i < R-1; i++){
		for(int k = 0; k < N; k++){
			if(min_Cost[i][k] == BIG_NUM)continue;

			current_town = sche[i];
			next_town = sche[i+1];
			current_shima_id = info[current_town].shima_id;
			next_shima_id = info[next_town].shima_id;

			if(current_shima_id == next_shima_id){

				if(land_dist[current_town][next_town] != BIG_NUM){
					min_Cost[i+1][k] = min(min_Cost[i+1][k],min_Cost[i][k]+land_dist[current_town][next_town]);
				}

				tmp = land_dist[current_town][k];
				for(int a = 0; a < MINATO[current_shima_id].size();a++){
					next_minato = MINATO[current_shima_id][a];
					if(next_minato == k)continue;

					if(sea_dist[k][next_minato] != BIG_NUM && land_dist[next_minato][next_town] != BIG_NUM){
						min_Cost[i+1][next_minato] = min(min_Cost[i+1][next_minato],min_Cost[i][k]+tmp+sea_dist[k][next_minato]+land_dist[next_minato][next_town]);
					}
				}

			}else{

				tmp = land_dist[current_town][k];

				for(int a = 0; a < MINATO[next_shima_id].size();a++){
					next_minato = MINATO[next_shima_id][a];

					if(sea_dist[k][next_minato] != BIG_NUM && land_dist[next_minato][next_town] != BIG_NUM){
						min_Cost[i+1][next_minato] = min(min_Cost[i+1][next_minato],min_Cost[i][k]+tmp+sea_dist[k][next_minato]+land_dist[next_minato][next_town]);
					}
				}

			}
		}
	}

	int ans = BIG_NUM;
	for(int i = 0; i < N; i++)ans = min(ans,min_Cost[R-1][i]);

	printf("%d\n",ans);
}

int main(){

	while(true){

		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3788