#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;


ll dp[1010][210];
ll riku[210][210], fune[210][210];



int main(){
	int n, m;
	while(cin >> n >> m && (n | m)) {
		rep(i, 1010) rep(j, 210) dp[i][j] = LINF;
		rep(i, 210) rep(j, 210) riku[i][j] = fune[i][j] = (i == j ? 0LL : LINF);
		rep(i, m) {
			int a, b;
			ll t;
			string s;
			cin >> a >> b >> t >> s;
			a--; b--;
			if(s == "L") riku[a][b] = riku[b][a] = min(riku[a][b], t);
			else fune[a][b] = fune[b][a] = min(fune[a][b], t);
		}
		rep(k, n) rep(i, n) rep(j, n) {
			riku[i][j] = min(riku[i][j], riku[i][k] + riku[k][j]);
			fune[i][j] = min(fune[i][j], fune[i][k] + fune[k][j]);
		}
		int r;
		cin >> r;
		vi v(r);
		rep(i, r) cin >> v[i], v[i]--;
		dp[0][v[0]] = 0LL;
		rep(i, r - 1) {
			rep(j, n) if(dp[i][j] != LINF) {
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + riku[v[i]][v[i+1]]);
				rep(k, n) {
					dp[i+1][k] = min(dp[i+1][k], dp[i][j] + riku[v[i]][j] + fune[j][k] + riku[k][v[i+1]]);
				}
			}
		}
		ll ans = LINF;
		for(int i = 0; i < 210; i++) ans = min(ans, dp[r-1][i]);
		cout<<ans<<endl;
 	}
	
}