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

#include	<cstring>

#include	<iostream>

#include	<algorithm>



using	namespace	std;

const	int INF = 100000000;

const	int N = 210, M = 1010;



int n, m;

int z[M], d[M][N];

int dl[N][N], ds[N][N];



int main()

{

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

	{

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

		{

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

			{

				if( i == j )

					dl[i][j] = ds[i][j] = 0;

				else

					dl[i][j] = ds[i][j] = INF;

			}

		}

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

		{

			char s[2];

			int u, v, t;

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

			u --, v --;

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

			{

				dl[u][v] = min( dl[u][v], t );

				dl[v][u] = dl[u][v];

			}

			else

			{

				ds[u][v] = min( ds[u][v], t );

				ds[v][u] = ds[u][v];

			}

		}

		int r;

		scanf( "%d", &r );

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

		{

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

			z[i] --;

		}

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

		{

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

			{

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

				{

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

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

				}

			}

		}

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

			for( int j = 0; j < N; j ++ )

				d[i][j] = INF;

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

			d[0][i] = ds[z[0]][i] + dl[i][z[0]];

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

		{

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

			{

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

				{

					if( j != k )

						d[i][j] = min( d[i][j], d[i-1][k] + dl[z[i-1]][k] + ds[k][j] + dl[j][z[i]] );

					else

						d[i][j] = min( d[i][j], d[i-1][j] + dl[z[i-1]][z[i]] );

				}

			}

		}

		int ans = INF;

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

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

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

	}

	return 0;

}

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

#include<cstring>

#include<algorithm>

using namespace std;

#define MAXN 205

#define MAXR 1005

#define MAXM 10005

int N,M,R;

int S[MAXN][MAXN],L[MAXN][MAXN];

int task[MAXR];

int dp[MAXR][MAXN];

int main()

{

	while(1)

	{

		scanf("%d%d",&N,&M);

		if(!N&&!M)break;

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

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

				S[i][j]=L[i][j]=1000000;

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

			S[i][i]=L[i][i]=0;

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

		{

			int a,b,t;char s[3];

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

			if(s[0]=='S')

			{

				S[a][b]=min(S[a][b],t);

				S[b][a]=min(S[b][a],t);

			}

			else

			{

				L[a][b]=min(L[a][b],t);

				L[b][a]=min(L[b][a],t);

			}

		}

		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]);

				}

		scanf("%d",&R);

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

			scanf("%d",task+i);

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

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

				dp[i][j]=1000000;

		dp[1][task[1]]=0;

		for(int i=2;i<=R;i++)//the Captain position

			for(int j=1;j<=N;j++)//the Ship position

			{

				dp[i][j]=min(dp[i][j],dp[i-1][j]+L[task[i-1]][task[i]]);

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

					dp[i][k]=min(dp[i][k],dp[i-1][j]+L[task[i-1]][j]+S[j][k]+L[k][task[i]]);

			}

		int ans=0x7FFFFFFF;

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

			ans=min(ans,dp[R][i]);

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

	}

	return 0;

}