// 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.940055060498018x):
#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;

}