#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 1LL<<60
typedef long long ll;

int N, M;

ll d1[200][200]; // Land
ll d2[200][200]; // Sea

ll dp[1010][200];

int R;
int Z[1010];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (cin >> N >> M)
	{
		if (N == 0) return 0;
		
		rep(i, 0, N) rep(j, 0, N) d1[i][j] = d2[i][j] = INF;
		rep(i, 0, N) d1[i][i] = d2[i][i] = 0;

		rep(i, 0, M)
		{
			int x, y, t; char sl;
			cin >> x >> y >> t >> sl;
			x--; y--;

			if (sl == 'L')
				d1[x][y] = d1[y][x] = t;
			else
				d2[x][y] = d2[y][x] = t;
		}

		rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
			d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
		rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
			d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);

		cin >> R;
		rep(i, 0, R) cin >> Z[i];
		rep(i, 0, R) Z[i]--;

		rep(i, 0, R) rep(j, 0, N) dp[i][j] = INF;
		dp[0][Z[0]] = 0;

		rep(i, 0, R - 1) rep(j, 0, N) if (dp[i][j] != INF)
		{
			ll dd = dp[i][j] + d1[Z[i]][Z[i + 1]];
			dp[i + 1][j] = min(dp[i + 1][j], dd);

			rep(k, 0, N)
			{
				dd = dp[i][j] + d1[Z[i]][j] + d2[j][k] + d1[k][Z[i + 1]];
				dp[i + 1][k] = min(dp[i + 1][k], dd);
			}
		}

		ll ans = INF;
		rep(i, 0, N) ans = min(ans, dp[R - 1][i]);
		cout << ans << endl;
	}
}