//{Headers
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<queue>
#include<deque>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp(x,y) make_pair(x,y)
typedef long long ll;
//}

const int MAXN=200,MAXR=1000;
const ll INF64=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
int N,R,z[MAXR+1];
ll s[MAXN+1][MAXN+1],l[MAXN+1][MAXN+1],dp[2][MAXN+1];

void init(){
    memset(s,INF,sizeof s);
    memset(l,INF,sizeof l);
    for(int i=1;i<=N;i++) s[i][i]=l[i][i]=0;
}

void Floyd(ll g[MAXN+1][MAXN+1]){
    for(int k=1;k<=N;k++) for(int i=1;i<=N;i++) for(int j=1;j<=N;j++)
        if(g[i][j]>g[i][k]+g[k][j])
            g[i][j]=g[i][k]+g[k][j];
}

void solve(){
    Floyd(s);
    Floyd(l);
    memset(dp,INF,sizeof dp);
//    for(int i=1;i<=N;i++)
//        dp[0][i]=min(INF64,s[z[1]][i]+l[z[1]][i]);
    z[0]=z[1];
    dp[0][z[1]]=0;
#define last ((i+1)%2)
#define curr (i%2)
    /*
     *              | Location | Boat |
     * -------------+----------+------|
     * dp[last][lb] |  Z[i-1]  |  lb  |
     * dp[curr][cb] |   Z[i]   |  cb  |
     *
     *                       L       S       L
     *   Move order: Z[i-1] ---> lb ---> cb ---> Z[i]
     *                      L       S       L
     * Search order: Z[i] <--- cb <--- lb <--- Z[i-1]
     */
/* First cb, second lb */
    for(int i=1;i<=R;i++) for(int cb=1;cb<=N;cb++){
        dp[curr][cb]=min(dp[last][cb]+l[z[i-1]][z[i]],INF64);
        if(l[z[i]][cb]==INF64) continue;
        for(int lb=1;lb<=N;lb++){
            if(s[lb][cb]==INF64 || l[z[i-1]][lb]==INF64 || dp[last][lb]==INF64)
                continue;
            int dt=dp[last][lb]+l[z[i-1]][lb]+s[lb][cb]+l[cb][z[i]];
            if(dp[curr][cb]>dt)
                dp[curr][cb]=dt;
        }
    }
/* First lb, second cb */
//    for(int i=1;i<=R;i++){
//        for(int j=1;j<=N;j++) dp[curr][j]=INF64;
//        for(int lb=1;lb<=N;lb++) if(dp[last][lb]!=INF64){
//            dp[curr][lb]=min(dp[last][lb]+l[z[i-1]][z[i]],dp[curr][lb]);
//            if(l[z[i-1]][lb]==INF64) continue;
//            for(int cb=1;cb<=N;cb++){
//                if(s[lb][cb]==INF64 || l[z[i]][cb]==INF64 || dp[last][lb]==INF64)
//                    continue;
//                int dt=dp[last][lb]+l[z[i-1]][lb]+s[lb][cb]+l[cb][z[i]];
//                if(dp[curr][cb]>dt)
//                    dp[curr][cb]=dt;
//            }
//        }
//    }
#undef last
#undef curr
    ll ans=INF64;
    for(int i=1;i<=N;i++) if(dp[R%2][i]<ans)
        ans=dp[R%2][i];
    printf("%lld\n",ans);
}

int main(void){
//    freopen("in.txt","r",stdin);
    int x,y,M;
    ll t;
    char sl;
    while(~scanf("%d%d",&N,&M) && N!=0){
        init();
        for(int i=0;i<M;i++){
            scanf("%d%d%lld %c ",&x,&y,&t,&sl);
            if(sl=='S') s[x][y]=s[y][x]=min(s[x][y],t);
            else l[x][y]=l[y][x]=min(l[x][y],t);
        }
        scanf("%d",&R);
        for(int i=1;i<=R;i++) scanf("%d",&z[i]);
        solve();
    }
    return 0;
}

/*
Sample Input
3 3
1 2 5 L
1 2 7 S
2 3 11 S
3
1 2 3
5 5
1 2 15 L
2 3 10 L
4 5 7 L
1 3 30 S
3 4 100 S
5
1 3 5 4 1
0 0
Output for the Sample Input
18
269
*/



Measured memory_bytes: 3768