# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define MP make_pair
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl
# define INIT(a) memset(a,-1,sizeof a)
# define CLR(a) memset(a,0,sizeof a)
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

struct P
{
	int now, ship, cost, job;
	P(int now, int ship, int cost, int job) :now(now), ship(ship), cost(cost), job(job) {}
	bool operator<(const P &other)const { return cost < other.cost; }
	bool operator>(const P &other)const { return cost > other.cost; }
};
signed main()
{
	while ( true )
	{
		int N, M;
		int SeaRoutes[201][201];
		int LandRoutes[201][201];
		int R;
		vi Destinations;
		cin >> N >> M;
		if ( N == 0 && M == 0 )break;
		FOR(i, 201)FOR(j, 201)SeaRoutes[i][j] = LandRoutes[i][j] = INF;
		FOR(i, 201)SeaRoutes[i][i] = LandRoutes[i][i] = 0;
		FOR(i, M)
		{
			int x, y, t;
			char sl;
			cin >> x >> y >> t >> sl;
			if ( sl == 'S' )
			{
				SeaRoutes[x][y] = min(SeaRoutes[x][y], t);
				SeaRoutes[y][x] = min(SeaRoutes[y][x], t);
			}
			else
			{
				LandRoutes[x][y] = min(LandRoutes[x][y], t);
				LandRoutes[y][x] = min(LandRoutes[y][x], t);
			}
		}
		cin >> R;
		FOR(i, R)
		{
			int z;
			cin >> z;
			Destinations.push_back(z);
		}
		FOR(k, N + 1)FOR(i, N + 1)FOR(j, N + 1)
		{
			SeaRoutes[i][j] = min(SeaRoutes[i][j], SeaRoutes[i][k] + SeaRoutes[k][j]);
			LandRoutes[i][j] = min(LandRoutes[i][j], LandRoutes[i][k] + LandRoutes[k][j]);
		}
		int Flag[201][1001];
		FOR(i, 201)FOR(j, 1001)Flag[i][j] = INF;
		priority_queue< P, vector<P>, greater<P> >Queue;
		Queue.push(P(Destinations[0], Destinations[0], 0, 1));
		while ( !Queue.empty() )
		{
			P Current = Queue.top(); Queue.pop();
			if ( Current.job == R )
			{
				cout << Current.cost << endl;
				break;
			}
			const int Destination = Destinations[Current.job];
			const int now = Current.now;
			const int ship = Current.ship;

			if ( LandRoutes[now][Destination] < INF )
			{
				P A = Current;
				A.cost += LandRoutes[now][Destination];
				A.now = Destination;
				A.job++;
				if ( Flag[A.ship][A.job]>A.cost )
				{
					Queue.push(A);
					Flag[A.ship][A.job] = A.cost;
				}
			}


			FOR(i, N + 1)
			{
				if ( SeaRoutes[ship][i] < INF&&LandRoutes[i][Destination] < INF )
				{
					P A = Current;
					A.cost += LandRoutes[now][ship] + SeaRoutes[ship][i] + LandRoutes[i][Destination];
					A.now = Destination;
					A.ship = i;
					A.job++;
					if ( Flag[A.ship][A.job] > A.cost )
					{
						Queue.push(A);
						Flag[A.ship][A.job] = A.cost;
					}
				}
			}

		}
	}
}

Measured memory_bytes: 4304