#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)

const ll INF = 1LL << 60;

int solve() {
    int N, M; cin >> N >> M;
    if (N == 0) return 0;
    
    vector<vector<ll>> dist_l(N, vector<ll>(N, INF));
    vector<vector<ll>> dist_s(N, vector<ll>(N, INF));
    REP(i, N) dist_l[i][i] = 0;
    REP(i, N) dist_s[i][i] = 0;
    REP(_, M) {
        int x, y; ll t; char sl; cin >> x >> y >> t >> sl;
        if (sl == 'S') {
            dist_s[x - 1][y - 1] = min(dist_s[x - 1][y - 1], t);
            dist_s[y - 1][x - 1] = min(dist_s[y - 1][x - 1], t);
        } else {
            dist_l[x - 1][y - 1] = min(dist_l[x - 1][y - 1], t);
            dist_l[y - 1][x - 1] = min(dist_l[y - 1][x - 1], t);
        }
    }


    REP(i, N) REP(j, N) REP(k, N)
        dist_s[j][k] = min(dist_s[j][k], dist_s[j][i] + dist_s[i][k]);
    REP(i, N) REP(j, N) REP(k, N)
        dist_l[j][k] = min(dist_l[j][k], dist_l[j][i] + dist_l[i][k]);


    int R; cin >> R;
    vector<int> dests;
    REP(_, R) {
        int r; cin >> r;
        dests.push_back(r - 1);
    }


    vector<vector<ll>> dp(R, vector<ll>(N, INF));
    dp[0][dests[0]] = 0;

    REP2(i, 1, R) REP(j, N) REP(k, N) {
        dp[i][j] = min(dp[i][j], dp[i-1][k] + dist_l[dests[i-1]][k] + dist_s[k][j] + dist_l[j][dests[i]]);
        if (j == k)
            dp[i][j] = min(dp[i][j], dp[i-1][k] + dist_l[dests[i-1]][dests[i]]);

    }

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

    return 1;
}

int main() {
    while (solve());
    return 0;
}