// 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.7904936210907778x):
#include    <iostream>

#include    <cstdio>

#include    <cstdlib>

#include    <algorithm>

#include    <vector>

#include    <cstring>

#include    <queue>

#include    <complex>

#include    <stack>

#define LL long long

#define dob double

using namespace std;



const int N = 210;

const int R = 1010;

const int Inf = 1<<28;

int n,m,Q,land[N][N],sea[N][N],f[R][N],Cit[R],Ans;



inline int gi(){

  int x=0,res=1;char ch=getchar();

  while(ch>'9'||ch<'0'){if(ch=='-')res*=-1;ch=getchar();}

  while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();

  return x*res;

}



main()

{

  /*freopen("Mr._Rito_Post_Office .in","r",stdin);

    freopen("Mr._Rito_Post_Office .out","w",stdout);*/

  while(1){

    n=gi();m=gi();

    if(n+m==0)break;

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

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

        land[i][j]=sea[i][j]=Inf;

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

      land[i][i]=sea[i][i]=0;

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

      int u,v,c;char type;

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

      if(type=='L')

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

      else sea[u][v]=sea[v][u]=min(sea[u][v],c);

    }

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

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

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

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

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

        }

    Q=gi();

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

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

        f[i][j]=Inf;Ans=Inf;

    for(int i=1;i<=Q;++i)Cit[i]=gi();

    f[1][Cit[1]]=0;

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

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

        f[i][j]=min(f[i][j],f[i-1][j]+land[Cit[i-1]][Cit[i]]);

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

          f[i][j]=min(f[i][j],f[i-1][k]+land[Cit[i-1]][k]+sea[j][k]+land[j][Cit[i]]);

      }

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

      Ans=min(Ans,f[Q][i]);

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

  }

  

  /*fclose(stdin);

    fclose(stdout);*/

  return 0;

}