#define DEBUG_ON_
#define CONDITION true
using namespace std;/*{{{*/

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define INF (1e8)
static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)

#define IFC(c) if(c) continue;
#define IFB(c) if(c) break;
#define IFR(c, r) if(c) return r;

#define OPOVER(_op, _type) inline bool operator _op (const _type &t) const

#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )

#define F first
#define S second
#define MP(a, b) make_pair(a, b)

#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(c,it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m) & 1)

#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))

#ifdef DEBUG_ON
	#define dprt(fmt, ...) if (CONDITION) fprintf(stderr, fmt, __VA_ARGS__)
	#define darr(a) if (CONDITION) copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define darr_range(a, f, t) if (CONDITION) copy( (a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define dvec(v) if (CONDITION) copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define darr2(a, n, m) if (CONDITION) FOR(i, 0, (n)){ darr_range( (a)[i], 0, (m) ); }
	#define dvec2(v) if (CONDITION) FOR(i, 0, SZ(v)){ dvec( (v)[i] ); }
	#define WAIT() if (CONDITION) { string _wait_; cerr << "(hit return to continue)" << endl; getline(cin, _wait_); }
#else
	#define cerr if(0) cerr
	#define dprt(fmt, ...)
	#define darr(a)
	#define darr_range(a, f, t)
	#define dvec(v)
	#define darr2(a, n, m)
	#define dvec2(v)
	#define WAIT()
#endif/*}}}*/

#define MAX_V 200

int dl[MAX_V][MAX_V];
int ds[MAX_V][MAX_V];

int main(int argc, char const* argv[])
{
	int N, M;
	while (cin >> N >> M, N || M) {
		REP (i, MAX_V) {
			REP (j, MAX_V) {
				if (i == j) {
					dl[i][j] = 0; ds[i][j] = 0;
				} else {
					dl[i][j] = INF;
					ds[i][j] = INF;
				}
			}
		}
		REP (i, M) {
			int x, y, t; char s;
			cin >> x >> y >> t >> s; --x; --y;
			if (s == 'L') {
				dl[x][y] = dl[y][x] = min(dl[x][y], t);
			} else {
				ds[x][y] = ds[y][x] = min(ds[x][y], t);
			}
		}
		int R; cin >> R;
		vector<int> towns;
		REP (i, R) {
			int z; cin >> z; --z;
			towns.PB(z);
		}

		// Warshall Floyd
		REP (k, N) {
			REP (i, N) {
				REP (j, N) {
					dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
					ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
				}
			}
		}

		#define MAX_R 1000
		int dp[MAX_R][MAX_V];
		REP (i, MAX_R) {
			REP (j, MAX_V) {
				dp[i][j] = INF;
			}
		}

		int rito = towns[0];
		int ship = towns[0];
		dp[0][ship] = 0;
		FOR (i, 1, R) {
			int rfrom = towns[i-1];
			int rto = towns[i];
			dprt("Rito \"Next town is #%d.\"\n", rto);
			REP (j, N) {
				dprt("\tI will put my ship on town #%d.\n", j);
				int sto = j;
				REP (k, N) {
					int sfrom = k;
					dprt("\t\tWhen I was on #%d and ship was on #%d, cost was %d\n", rfrom, sfrom, dp[i-1][sfrom]);
					dp[i][sto] = min(dp[i][sto], dp[i-1][sfrom] + dl[rfrom][sfrom] + ds[sfrom][sto] + dl[sto][rto]);
					if (sfrom == sto) {
						dp[i][sto] = min(dp[i][sto], dp[i-1][sfrom] + dl[rfrom][rto]);
					}
				}
				dprt("\tIt costs %d\n", dp[i][sto]);
			}
		}
		
		int ans = INF;
		REP (i, N) {
			ans = min(ans, dp[R-1][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2012