// 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.5816815940752946x):
#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<string>

#define inf 0x3f3f3f3f

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 (scanf("%d%d",&n,&m),n+m)

	{

		memset(land, inf, sizeof(land));

		memset(sea, inf, sizeof(sea));

		memset(dp, inf, sizeof(dp));

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

		{

			int a, b, c;

			string str;

			scanf("%d%d%d", &a, &b, &c);

			cin >> str;

			if (str == "S")

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

			else

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

		}

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

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

		scanf("%d", &r);

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

			scanf("%d", tar + i);

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

				}

		//dp[i][j]代表到达了第i个要求达到的小镇tar[i]，船停在j镇。所花费的最小时间

		dp[1][tar[1]] = 0;

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

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

			{

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

				for (int k = 1; k <= n; 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 = inf;

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

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

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

	}

	return 0;

}