N;
C[2][201][201];
DP[1000][201];
WF(int c[201][201]){
	int i,j,k;
	for(k=1;k<=N;k++)
		for(i=1;i<=N;i++)
			for(j=1;j<=N;j++)
				c[i][j]=fmin(c[i][j],c[i][k]+c[k][j]);
	for(i=1;i<=N;i++)
		c[i][i]=0;
}
main(){
	int M,R,s,d,i,boat,k,c;
	for(;scanf("%d%d",&N,&M)*N;){
		memset(C,1,sizeof(C));//inf
		for(;M--;){
			int x,y,t,s;
			char sl[2];
			scanf("%d%d%d%s",&x,&y,&t,sl);
			s=sl[0]=='L'?0:1;
			C[s][x][y]=C[s][y][x]=fmin(C[s][x][y],t);
		}
		WF(C[0]);
		WF(C[1]);
		memset(DP,1,sizeof(*DP));//inf
		scanf("%d%d",&R,&s);
		DP[0][s]=0;
		for(i=1;i<R;i++){
			scanf("%d",&d);
			for(boat=1;boat<=N;boat++){
				DP[i][boat]=DP[i-1][boat]+C[0][s][d];
				for(k=1;k<=N;k++){
					DP[i][boat]=fmin(DP[i][boat],
						DP[i-1][k]+C[0][s][k]+C[1][k][boat]+C[0][boat][d]);
				}
			}
			s=d;
		}
		c=1e9;
		for(boat=1;boat<=N;boat++){
			c=fmin(c,DP[i-1][boat]);
		}
		printf("%d \n",c);
	}
}