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

#include<cstdio>

#include<cstring>

using namespace std;

const int inf=0x3f3f3f3f;

const int maxn=2e2+10;

int n,m,num;

int costl[maxn][maxn],costs[maxn][maxn];

int dp[1005][maxn];

int a[1005];

int main()

{

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

    {

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

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

            {

                if(i==j)

                {

                    costl[i][j]=costs[i][j]=0;

                }

                else

                {

                     costl[i][j]=costs[i][j]=inf/3;

                }

            }

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

        {

            char s[2];

            int x,y,val;

            scanf("%d%d%d%s",&x,&y,&val,s);

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

            {

                costl[x][y]=costl[y][x]=min(val,costl[x][y]);

            }

            else

            {

                costs[x][y]=costs[y][x]=min(val,costs[x][y]);

            }

        }

        scanf("%d",&num);

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

        {

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

        }

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

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

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

                {

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

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

                }

        memset(dp,0x3f,sizeof(dp));

        dp[1][a[1]]=0;

        for(int i=2;i<=num;i++)

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

            {

                dp[i][j]=min(dp[i][j],dp[i-1][j]+costl[a[i-1]][a[i]]);

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

                {

                    //dp[i][k]=min(dp[i][k],dp[i-1][j]+costl[a[i-1]][j]+costs[j][k]+costl[k][a[i]]);

                    dp[i][j]=min(dp[i][j],dp[i-1][k]+costl[a[i-1]][k]+costs[k][j]+costl[j][a[i]]);

                }

            }

        int ans=inf;

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

        {

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

        }

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

    }

}

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

#include <algorithm>

using namespace std;

 

#define INF 1e8

#define MAX_V 256

#define MAX_R 1024

int dl[MAX_V][MAX_V];	//	d[u][v]表示?e=(u,v)的??，不存在的?候等于无?大或者d[i][i] = 0

int ds[MAX_V][MAX_V];

int z[MAX_R];

int dp[MAX_R][MAX_V];	// dp[i][j] := 已?去了第i个?子后，船停在第j个?子里

int N;					//	?点数

 

///////////////////////////SubMain//////////////////////////////////

int main(int argc, char *argv[])

{

 

	int M;

	while (cin >> N >> M , N || M)

	{

// 		memset(dl, 0x3f, sizeof(dl));

// 		memset(ds, 0x3f, sizeof(ds));

		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)

		{

			int x, y, t;

			char s;

			cin >> x >> y >> t >> s;

			--x; --y;

			if (s == 'L')

			{

				dl[x][y] = min(dl[x][y], t);

				dl[y][x] = dl[x][y];

			}

			else

			{

				ds[x][y] = min(ds[x][y], t);

				ds[y][x] = ds[x][y];

			}

		}

		

		int R;

		cin >> R;

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

		{

			cin >> z[i];

			--z[i];

		}

 

		// warshall_floyd

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

				}

			}

		}

		// end of warshall_floyd

 

		// dp

		// 尼?3个0x3f3f3f3f加起来溢出了

		//memset(dp, 0x3f, sizeof(dp));

		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)

		{

			// 去了首个?子后，船放在第i个?子里

						// 坐船去	 // 坐11路?回来

			dp[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)

					{

						//                          i-1站     + 从i-1站走旱路去j+ 从j走水路去k+从k走旱路去i

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

					}

					else

					{

						// j == k                   i-1站     + 从i-1站走旱路去i

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

					}

				}

			}

		}

 

		cout << *min_element(dp[R - 1], dp[R - 1] + N) << endl;

	}

 

	return 0;

}