#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/5

int n,m,r;
int dl[222][222];
int ds[222][222];
int dp[1111][222];
int rs[1111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,222)rep(j,222){
      dl[i][j]=i==j?0:INF;
      ds[i][j]=i==j?0:INF;
    }
    rep(i,1111)rep(j,222)dp[i][j]=INF;
    rep(i,m){
      int x,y,t; string sl;
      cin>>x>>y>>t>>sl; x--; y--;
      if(sl=="L"){
        dl[x][y]=dl[y][x]=t;
      }else{
        ds[x][y]=ds[y][x]=t;
      }
    }
    rep(k,n)rep(i,n)rep(j,n){
      minch(dl[i][j],dl[i][k]+dl[k][j]);
      minch(ds[i][j],ds[i][k]+ds[k][j]);
    }
    cin>>r;
    rep(i,r){
      cin>>rs[i];
      rs[i]--;
    }
    dp[0][rs[0]]=0;
    rep(i,r-1){
      int crt=rs[i],nxt=rs[i+1];
      rep(j,n){
        minch(dp[i+1][j],dp[i][j]+dl[crt][nxt]);
        if(crt==j){
          rep(k,n)minch(dp[i+1][k],dp[i][j]+ds[crt][k]+dl[k][nxt]);
        }
        rep(k,n)minch(dp[i+1][k],dp[i][j]+dl[crt][j]+ds[j][k]+dl[k][nxt]);
      }
    }
    int res=INF;
    rep(j,n)minch(res,dp[r-1][j]);
    cout<<res<<endl;
  }
	return 0;
}