#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int n,m,r,dr[200][200],ds[200][200],inf=4*1e8;
int main(){
	while(true){
		cin>>n>>m;
		if(n==0) break;
		rep(i,n) rep(j,n) if(i!=j) dr[i][j]=inf,ds[i][j]=inf;
		rep(i,m){
			int x,y,t;
			char s;
			cin>>x>>y>>t>>s;
			x--,y--;
			if(s=='L'){
				dr[x][y]=min(dr[x][y],t);
				dr[y][x]=min(dr[y][x],t);
			}else{
				ds[x][y]=min(ds[x][y],t);
				ds[y][x]=min(ds[y][x],t);
			}
		}
		rep(i,n) rep(j,n) rep(k,n) dr[j][k]=min(dr[j][k],dr[j][i]+dr[i][k]);
		rep(i,n) rep(j,n) rep(k,n) ds[j][k]=min(ds[j][k],ds[j][i]+ds[i][k]);
		cin>>r;
		int ans[200],nans[200];
		rep(i,n) ans[i]=inf,nans[i]=inf;
		int v,p;
		cin>>p;
		p--;
		ans[p]=0;
		rep(i,r-1){
			cin >> v;
			v--;
			rep(j,n) rep(k,n){
				if(j==k) nans[k]=min(nans[k],ans[j]+dr[p][v]);
				else nans[k]=min(nans[k],ans[j]+dr[p][j]+ds[j][k]+dr[k][v]);
			}
			p=v;
			rep(j,n) ans[j]=nans[j],nans[j]=inf;
		}
		int aans=inf;
		rep(i,n) aans=min(aans,ans[i]);
		cout << aans << endl;
	}
}