//can solve problem with negative loop/cycle
//worst O(V^3)
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>

using namespace std;

const int INF = 0x7fffffff;
const int MAXV=200+5;
const int MAXR=1000+5;

int schedule[MAXR];
int V;

struct Node {
    int mina; // can use any way
    int minl; // only use land way
    int mins; // only use sea way
    int pre_ship_pos;
};

Node dd[MAXV][MAXV];  //d[u][v] means cost[u][v], d[i][i]=0, no edge = INF
Node min_dis[MAXV][MAXR];

//return false means have negative loop, true means no negative loop
bool warshall_floyd(Node d[][MAXV])
{
    for(int k=0;k<V;++k)
    {
        for(int i=0;i<V;++i)
        {
            for(int j=0;j<V;++j)
            {
                if(d[i][k].minl!=INF && d[k][j].minl!=INF)
                {
                    if(d[i][j].minl > d[i][k].minl+d[k][j].minl)
                    {
                        d[i][j].minl = d[i][k].minl + d[k][j].minl;
                        if(d[i][j].minl<d[i][j].mina)
                        {
                            d[i][j].mina = d[i][j].minl;
                            d[i][j].pre_ship_pos = i;
                        }
                    }
                }
                if(d[i][k].mins!=INF && d[k][j].mins!=INF)
                {
                    if(d[i][j].mins > d[i][k].mins+d[k][j].mins)
                    {
                        d[i][j].mins = d[i][k].mins + d[k][j].mins;
                        if(d[i][j].mins<=d[i][j].mina)
                        {
                            d[i][j].mina = d[i][j].mins;
                            d[i][j].pre_ship_pos = j;
                        }
                    }
                }
                if(d[i][k].mins!=INF && d[k][j].mina!=INF)
                {
                    if(d[i][j].mina > d[i][k].mins+d[k][j].mina)
                    {
                        d[i][j].mina = d[i][k].mins + d[k][j].mina;
                        d[i][j].pre_ship_pos = k;
                    }
                }
                if(i==j&&d[i][i].mina<0)
                    return false;
            }
        }
    }
    return true;
}

void init()
{
    for(int i=0;i<V;++i) {
        for(int j=0;j<V;++j) {
            dd[i][j] = dd[i][j] = Node{INF, INF, INF, -1};
        }
        dd[i][i] = dd[i][i] = {0, 0, 0, i};
    }
}

void solve(int R)
{
    for(int i=0;i<R;++i){
        for(int j=0;j<V;++j)
            min_dis[j][i] = Node{INF,INF,INF,-1};
    }
    min_dis[schedule[0]][0] = Node {0,0,0,schedule[0]};   
    for(int i=1;i<R;++i) {
        int from = schedule[i-1];
        int to = schedule[i];
        for(int j=0;j<V;++j) {
            if(dd[from][to].minl!=INF && min_dis[j][i-1].mina!=INF)
                min_dis[j][i].mina = min(min_dis[j][i].mina, min_dis[j][i-1].mina + dd[from][to].minl);
            //if(j==to && dd[from][to].mins!=INF && min_dis[j][i-1].mina!=INF)
                //min_dis[j][i].mina = min(min_dis[j][i].mina, min_dis[j][i-1].mina + dd[from][to].minl);
            for(int k=0;k<V;++k)
            {
                if(min_dis[k][i-1].mina!=INF && dd[from][k].minl!=INF && dd[k][j].mins!=INF && dd[j][to].minl!=INF)
                min_dis[j][i].mina = min(min_dis[j][i].mina, min_dis[k][i-1].mina+dd[from][k].minl+dd[k][j].mins+dd[j][to].minl);
            }
        }
    }

    int ans = INF;
    for(int j=0;j<V;++j) 
    {
        ans = min(ans, min_dis[j][R-1].mina);
    }
    printf("%d\n", ans);
}

int main()
{
    int M;
    while(scanf("%d%d", &V, &M)!=EOF) {
        if(V==0 && M==0) break;
        init();
        int u,v,w; char t;
        for(int i=0;i<M;++i) {
            scanf("%d %d %d %c", &u, &v, &w, &t);
            u--; v--;
            if(t=='S') {
                if(w<dd[u][v].mins)
                    dd[u][v].mins = dd[v][u].mins = w;
                if(w<dd[u][v].mina) {
                    dd[u][v].mina = dd[v][u].mina = w;
                    dd[u][v].pre_ship_pos = v;
                    dd[v][u].pre_ship_pos = u;
                }
            } else {
                if(w<dd[u][v].minl) 
                    dd[u][v].minl = dd[v][u].minl = w;
                if(w<dd[u][v].mina) {
                    dd[u][v].mina = dd[v][u].mina = w;
                    dd[u][v].pre_ship_pos = u;
                    dd[v][u].pre_ship_pos = v;
                }
            }
        }
        int R;
        scanf("%d", &R);
        int tmp;
        for(int i=0;i<R;++i){
            scanf("%d", &tmp);
            schedule[i] = tmp-1;
        }
        warshall_floyd(dd);
        solve(R);
    }
    return 0;
}


Measured memory_bytes: 6952