#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8;
const int MAX_V = 205;

void init(int m[MAX_V][MAX_V]){
	rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
	rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(int m[MAX_V][MAX_V], int n){
	rep(k,n){
		rep(i,n){
			rep(j,n){
				m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}
}

int main(){
	int n, m;
	while(cin >> n >> m, n){
		int riku[MAX_V][MAX_V];
		int umi[MAX_V][MAX_V];
		init(riku);
		init(umi);
		rep(i,m){
			int x, y, t;
			string sl;
			cin >> x >> y >> t >> sl;
			x--; y--;
			if(sl[0] == 'L') riku[x][y] = riku[y][x] = min(riku[x][y], t);
			else umi[x][y] = umi[y][x] = min(umi[x][y], t);
		}
		warshallFloyd(riku, n);
		warshallFloyd(umi, n);

		int r;
		cin >> r;
		vector<int> z(r);
		rep(i,r) cin >> z[i];
		for(auto& i : z) i--;

		vector<vector<int>> dp(r, vector<int>(n, INF));
		dp[0][z[0]] = 0;
		rep(i,r - 1){
			int cur = z[i];
			int nxt = z[i + 1];
			rep(j,n){
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + riku[cur][nxt]);
				rep(k,n){
					dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + riku[cur][j] +
							umi[j][k] + riku[k][nxt]);
				}
			}
		}

		//rep(i,n) cout << dp.back()

		cout << *min_element(all(dp.back())) << endl;
	}
}

