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

#include <string>

#include <vector>

#include <cmath>

#include <algorithm>

#include <cstdlib>

#include <ctime>

#include <cstdio>

#include <functional>

#include <set>

#include <queue>

#include <cctype>

#include <climits>

#include <stack>

using namespace std;



int n,m,r;

const int INF=1e7;

int land[200][200],sea[200][200],z[1000];

typedef pair<int,int> P;

typedef pair<P,int> PP;



struct edge{

	int to,cost;

	inline edge(int t,int c){

		to=t,cost=c;

	}	

};



// ?????????????????????n?????????

priority_queue<P,vector<P>,greater<P> > q;

vector<edge> GS[200],GL[200];

int dl[200][200],ds[200][200];



int main(){





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

		

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

			for(int j=0;j<n;j++) dl[i][j]=ds[i][j]=land[i][j]=sea[i][j]=INF;

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

			dl[i][i]=ds[i][i]=0;

			GS[i].clear();

			GL[i].clear();

		}

		

		

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

			int x,y,t;

			char c;

			scanf("%d %d %d %c",&x,&y,&t,&c);

			x--; y--;

			if(c=='S'){

				GS[x].push_back(edge(y,t));

				GS[y].push_back(edge(x,t));

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

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

			}else{

				GL[x].push_back(edge(y,t));

				GL[y].push_back(edge(x,t));

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

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

			}

		}

		

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

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

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

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

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

				}

			}

		}

		

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

			

			ds[i][i]=0;

			q.push(P(0,i));

			while(!q.empty()){

				

				P p=q.top(); q.pop();

				int cost=p.first,pos=p.second;

				if(ds[i][pos]<cost) continue;

				

				for(int j=0;j<GS[pos].size();j++){

					edge e=GS[pos][j];

					if(ds[i][e.to]>ds[i][pos]+e.cost){

						ds[i][e.to]=ds[i][pos]+e.cost;

						q.push(P(ds[i][e.to],e.to));

					}

				}

				

			}



			dl[i][i]=0;

			q.push(P(0,i));

			while(!q.empty()){

				

				P p=q.top(); q.pop();

				int cost=p.first,pos=p.second;

				if(dl[i][pos]<cost) continue;

				

				for(int j=0;j<GL[pos].size();j++){

					edge e=GL[pos][j];

					if(dl[i][e.to]>dl[i][pos]+e.cost){

						dl[i][e.to]=dl[i][pos]+e.cost;

						q.push(P(dl[i][e.to],e.to));

					}

				}		

			}

		}

			

		scanf("%d",&r);

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

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

			z[i]--;

		}

		

		vector<vector<int> > dp(1001,vector<int>(201,INF));

		dp[0][z[0]]=0;



		int res2=INF;

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

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

				

				//z[i]???????????????????????¨??°???z[i-1]

				

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

					//????????????j?????§?§???????j??????k????????????k??????z[i]?????????				

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

					if(i==r-1 && res2>dp[i][k]) res2=dp[i][k];

				}

				

				//????????§?§????

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

				if(i==r-1 && res2>dp[i][j]) res2=dp[i][j];

			}

		}



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

		

	}

}

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

#include <string>

#include <vector>

#include <cmath>

#include <algorithm>

#include <cstdlib>

#include <ctime>

#include <cstdio>

#include <functional>

#include <set>

#include <queue>

#include <cctype>

#include <climits>

#include <stack>

using namespace std;

 

int n,m,r;

const int INF=1e7;

int d[2][200][200];

int dp[1001][200];

typedef pair<int,int> P;

 

int main(){

 

 

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

	    

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

		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;

		  d[0][i][i]=d[1][i][i]=0;

	   }

	    

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

		  int x,y,t;

		  char c;

		  scanf("%d %d %d %c",&x,&y,&t,&c);

		  x--; y--;

		  

		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);

		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);

	   }

	    

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

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

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

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

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

			 }

		  }

	   }

	   

	   int now,z;

	   scanf("%d",&r);

	   scanf("%d",&now); now--;



	   fill(dp[0],dp[1001],INF);

	   dp[0][now]=0;

	    

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

		   scanf("%d",&z); z--;

		   

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

			   dp[i+1][j]=min(dp[i+1][j],dp[i][j]+d[1][now][z]);

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

				   // 

				   dp[i+1][k]=min(dp[i+1][k],dp[i][j]+d[1][now][j]+d[0][j][k]+d[1][k][z]);

			   }

			   

			   

		   }

		   now=z;

	   }





/*

	   //int res=INF;

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

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

						    

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

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

				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];

			 }

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

			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];

		  }

	   }

*/

	   printf("%d\n",*min_element(dp[r-1],dp[r]));

	    

    }

}