// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>



using namespace std;



int s[210][210];//水路

int l[210][210];//?路

int d[1010][210];//dp

int b[1010];//目?路?



const int INF = 0x3f3f3f3f;



void Floyd(int n) 

{

	for (int k = 1; k <= n; ++k) 

	{

		for (int i = 1; i <= n; ++i) 

		{

			for (int j = 1; j <= n; ++j) 

			{

				s[i][j] = min(s[i][j], s[i][k] + s[k][j]);

				l[i][j] = min(l[i][j], l[i][k] + l[k][j]);

			}

		}

	}

}



int main() 

{

	int n, m, r;

	int u, v, c;

	char tp[2];



	while (scanf("%d%d", &n, &m) != EOF && n) 

	{

		memset(s, INF, sizeof(s));

		memset(l, INF, sizeof(l));

		memset(d, INF, sizeof(d));



		while (m--) 

		{

			scanf("%d%d%d%s", &u, &v, &c, tp);

			if (tp[0] == 'L') 

			{

				l[u][v] = min(l[u][v], c);

				l[v][u] = min(l[v][u], c);

			}

			else 

			{

				s[u][v] = min(s[u][v], c);

				s[v][u] = min(s[v][u], c);

			}

		}



		for (int i = 1; i <= n; ++i) 

		{

			l[i][i] = 0;

			s[i][i] = 0;

		}



		scanf("%d", &r);



		for (int i = 1; i <= r; ++i) 

		{

			scanf("%d", &b[i]);

		}



		Floyd(n);



		for (int i = 1; i <= n; ++i) 

		{

			d[1][i] = min(d[1][i], s[b[1]][i] + l[i][b[1]]);

		}



		for (int i = 1; i <= r; ++i) 

		{

			for (int j = 1; j <= n; ++j) 

			{

				//if (l[j][b[i]] >= INF) continue;

				for (int k = 1; k <= n; ++k) 

				{

					//if (d[i - 1][k] >= INF) continue;

					if (j == k) 

					{

						if (l[b[i - 1]][b[i]] < INF) 

						{

							d[i][j] = min(d[i][j], d[i - 1][k] + l[b[i - 1]][b[i]]);

						}

					}

					else 

					{

						//三个INF可能上溢

						if (l[b[i - 1]][k] < INF && s[k][j] < INF && l[j][b[i]] < INF) 

						{

							d[i][j] = min(d[i][j], d[i - 1][k] + l[b[i - 1]][k] + s[k][j] + l[j][b[i]]);

						}

					}

				}

			}

		}



		int ans = INF;

		for (int j = 1; j <= n; ++j) 

		{

			ans = min(ans, d[r][j]);

		}

		printf("%d\n", ans);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.786730392026757x):
#include<cstdio>

#include<string>

#include<sstream>

#include<cstring>

#include<cmath>

#include<vector>

#include<set>

#include<map>

#include<queue>

#include<stack>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

typedef pair<int,int> pa;

const int inf=1e8;

int mml[205][205],mms[205][205],dp[1005][205],num[1005];

int main(){

    int n,m,a,b,c,r;

    char str[5];

    while(scanf("%d%d",&n,&m)&&n){

        for(int i=0;i<n;i++){

            mml[i][i]=mms[i][i]=0;

            for(int j=i+1;j<n;j++){

                mml[i][j]=mml[j][i]=inf;

                mms[i][j]=mms[j][i]=inf;

            }

        }

        for(int i=0;i<m;i++){

            scanf("%d%d%d%s",&a,&b,&c,str);

            a--,b--;

            if(str[0]=='L'){

                mml[a][b]=mml[b][a]=min(mml[a][b],c);

            }else{

                mms[a][b]=mms[b][a]=min(mms[a][b],c);

            }

        }

        scanf("%d",&r);

        for(int i=0;i<r;i++){

            scanf("%d",&num[i]);

            num[i]--;

        }

        for(int k=0;k<n;k++){

            for(int i=0;i<n;i++){

                for(int j=0;j<n;j++){

                    mml[i][j]=min(mml[i][j],mml[i][k]+mml[k][j]);

                    mms[i][j]=min(mms[i][j],mms[i][k]+mms[k][j]);

                }

            }

        }

        for(int i=0;i<r;i++){

            for(int j=0;j<n;j++){

                dp[i][j]=inf;

            }

        }

        for(int i=0;i<n;i++){

            dp[0][i]=mms[num[0]][i]+mml[i][num[0]];

        }

        int ans=inf;

        for(int i=1;i<r;i++){

            for(int j=0;j<n;j++){

                for(int k=0;k<n;k++){

                    if(j!=k)

                        dp[i][k]=min(dp[i][k],dp[i-1][j]+mml[num[i-1]][j]+mms[j][k]+mml[k][num[i]]);

                    else dp[i][j]=min(dp[i][j],dp[i-1][j]+mml[num[i-1]][num[i]]);

                }

            }

        }

        for(int i=0;i<n;i++){

            ans=min(ans,dp[r-1][i]);

        }

        printf("%d\n",ans);

    }

    return 0;

}