// Original C++ solution (slower):
//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;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <algorithm>

#include <functional>

#include <cstdlib>

#include <sstream>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <deque>

#include <complex>

#include <vector>

#include <cstdio>

#include <cmath>

#include <utility>

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

#define all(c) (c).begin(),(c).end()

#define rall(c) (c).rbegin(),(c).rend()

#define ll long long

#define pb(a) push_back(a)

#define fi first

#define se second

using namespace std;

 

template<class T>inline string toString(T x){

        ostringstream sout; sout<<x; return sout.str();

}

const ll MOD=1e9+7;

const int inf=(ll)1e9;

const double PI=acos(-1.0);

 

 

 

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.precision(10);

    cout<<fixed;

    int n,m;

    while(cin>>n>>m,n){

        int ldp[201][201];

        int sdp[201][201];

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

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

                ldp[i][j]=inf;

                sdp[i][j]=inf;

            }

        }

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

            ldp[i][i]=0;

            sdp[i][i]=0;

        }

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

            int a,b,c;

            char d;

            cin>>a>>b>>c>>d;

            a--;b--;

            if(d=='L'){

                ldp[a][b]=c;

                ldp[b][a]=c;

            }else{

                sdp[a][b]=c;

                sdp[b][a]=c;

            }

        }

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

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

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

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

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

                }

            }

        }

        int r;cin>>r;

        int a[1002];

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

            cin>>a[i];

            a[i]--;

        }

        int dp[1001][201];

        for(int i=0;i<1001;i++)for(int j=0;j<201;j++)dp[i][j]=inf;

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

        for(int i=0;i<r-1;i++){

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

                if(dp[i][j]==inf)continue;

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

                    dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][j]+sdp[j][k]+ldp[k][a[i+1]]);

                    if(j==k)dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][a[i+1]]);

                }

            }

        }

        /*for(int i=0;i<r;i++){

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

                cerr<<dp[i][j]<<" ";

            }

            cerr<<"\n";

        }*/

        int ans=inf;

        for(int i=0;i<201;i++){

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

        }

        cout<<ans<<endl;

    }

    return 0;

}


// Fastest known solution for this problem: