// Slower C++ solution:
//include

//------------------------------------------

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cctype>

#include <string>

#include <cstring>

#include <ctime>

#include <climits>

#include <queue>



using namespace std;



//typedef

//------------------------------------------

typedef vector<int> VI;

typedef vector<VI> VVI;

typedef vector<string> VS;

typedef pair<int, int> PII;

typedef long long LL;



//container util

//------------------------------------------

#define ALL(a)  (a).begin(),(a).end()

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define MP make_pair

#define SZ(a) int((a).size())

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())



//repetition

//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define REP(i,n)  FOR(i,0,n)



//constant

//--------------------------------------------

const double EPS = 1e-10;

const double PI  = acos(-1.0);

const LL INF = 1e14;



LL dist_L[201][201];

LL dist_S[201][201];

LL dp[1001][201];

int main(){

  cin.tie(0);

  ios_base::sync_with_stdio(false);



  int N, M, R;

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

	fill((LL*)dist_L, (LL*)dist_L+201*201, INF);

	fill((LL*)dist_S, (LL*)dist_S+201*201, INF);



	REP(i,N) dist_L[i][i] = dist_S[i][i] = 0;

	REP(i,M){

	  LL x, y, t; char c;

	  cin >> x >> y >> t >> c;

	  --x, --y;

	  if(c == 'L')

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

	  else

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

	}

	

	REP(k,N) REP(i,N) REP(j,N){

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

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

	}



	cin >> R;

	VI RS(R);

	REP(i,R){

	  cin >> RS[i];

	  --RS[i];

	}



	// dp[i][j] :<=> i番目まで訪問が終わって船の位置がjのときの最小コスト

	fill((LL*)dp, (LL*)dp+1001*201, INF);

	dp[0][RS[0]] = 0;

	REP(i,R-1){

	  REP(u,N){

		REP(v,N){

		  dp[i+1][v] = min(dp[i+1][v],

						   // Rs[i] -> uを陸で、u -> vを海で、v->RS[i+1]を陸で移動

						   dp[i][u]+dist_L[RS[i]][u] + dist_S[u][v]+dist_L[v][RS[i+1]]

						   );

		}

		//陸のみ

		dp[i+1][u] = min(dp[i+1][u], dp[i][u]+dist_L[RS[i]][RS[i+1]]);

	  }

	}



	LL ans = INF;

	REP(u,N) ans = min(ans, dp[R-1][u]);

	cout << ans << endl;

  }  

  

  return 0;

}

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

#include<iostream>

#include<algorithm>

#include<cstring>

#include<string>

using namespace std;

int land[205][205],sea[205][205],tar[1005],dp[1005][205];

int main()

{

    int n,m,i,j,k,r;

    while(cin>>n>>m&&(n+m)){

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

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

            int a,b,c;string str;

            cin>>a>>b>>c>>str;

            if(str=="S")

                sea[a][b]=sea[b][a]=c;

            else

                land[a][b]=land[b][a]=c;

        }

        for(i=1;i<=n;i++)land[i][i]=sea[i][i]=0;//不要忘了这个..

        cin>>r;for(i=1;i<=r;i++)cin>>tar[i];

        for(k=1;k<=n;k++)//floyd初始化,至于那些不可能的,初始化完了肯定还是无穷大不可能

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

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

                }

        dp[1][tar[1]]=0;//初始化

        for(i=1;i<=r;i++)//从2开始也没问题

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

                dp[i][j]=min(dp[i][j],dp[i-1][j]+land[tar[i-1]][tar[i]]);//单纯走陆路的情况,从tar[i-1]到tar[i]

                for(k=1;k<=n;k++){//回到船停的j镇,水路从j到k,陆路k到tar[i],枚举k

                    dp[i][k]=min((long long)dp[i][k],(long long)dp[i-1][j]+land[tar[i-1]][j]+sea[j][k]+land[k][tar[i]]);

                 

                }

            }

        int ans=0x7f7f7f7f;

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

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

        cout<<ans<<endl;

    }



    return 0;

}