#include "bits/stdc++.h"
using namespace std;

//#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
//#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int n, m;
//Vi z;
//VVi GNDcost;  // from, to
//VVi SEAcost;  // from, to

VVi dp;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    while (cin >> n >> m, n) {
        VVi GNDcost = VVi(n+1, Vi(n+1, INT_MAX));
        VVi SEAcost = VVi(n+1, Vi(n+1, INT_MAX));

        REP(mi, 1, m+1) {
            int x, y, t; char sl; cin >> x >> y >> t >> sl;
            if (sl == 'L') {
                GNDcost[x][y] = min(GNDcost[x][y], t);
                GNDcost[y][x] = min(GNDcost[y][x], t);
            } else {
                SEAcost[x][y] = min(SEAcost[x][y], t);
                SEAcost[y][x] = min(SEAcost[y][x], t);
            }
        }

        REP(via, 1, n+1) {
            REP(from, 1, n+1) {
                REP(to, 1, n+1) {
                    if (from == to) GNDcost[from][to] = 0;
                    else if (GNDcost[from][via] != INT_MAX && GNDcost[via][to] != INT_MAX) {
                        GNDcost[from][to] = min(GNDcost[from][to],
                                GNDcost[from][via] + GNDcost[via][to]);
                    }
                }
            }
        }

        REP(via, 1, n+1) {
            REP(from, 1, n+1) {
                REP(to, 1, n+1) {
                    if (from == to) SEAcost[from][to] = 0;
                    else if (SEAcost[from][via] != INT_MAX && SEAcost[via][to] != INT_MAX) {
                        SEAcost[from][to] = min(SEAcost[from][to],
                                SEAcost[from][via] + SEAcost[via][to]);
                    }
                }
            }
        }

        int R; cin >> R;
        Vi z = Vi(R+1); REP(r, 1, R+1) cin >> z[r];
        dp = VVi(R+1, Vi(n+1, INT_MAX));

        REP(ship, 1, n+1) {
            if (SEAcost[z[1]][ship] != INT_MAX && GNDcost[z[1]][ship] != INT_MAX)
                dp[1][ship] = SEAcost[z[1]][ship] + GNDcost[z[1]][ship];
        }

        REP(p, 1, R) {
            int cur_pos = z[p];
            int next_pos = z[p+1];
            if (GNDcost[cur_pos][next_pos] != INT_MAX) {
                REP(ship_pos, 1, n+1) {
                    if (dp[p][ship_pos] != INT_MAX) {
                        dp[p+1][ship_pos] = dp[p][ship_pos] + GNDcost[cur_pos][next_pos];
                        if (dp[p][ship_pos] + GNDcost[cur_pos][next_pos] < 0) {
                            cout << "overflowed " << p+1 spc ship_pos << endl;
                            return 119;
                        }
                    }
                }
            }

            REP(ship_to, 1, n+1) {
                REP(ship_from, 1, n+1) {
                    if (dp[p][ship_from] == INT_MAX) continue;

                    int get_ship_time = GNDcost[cur_pos][ship_from];
                    int shipping_time = SEAcost[ship_from][ship_to];
                    int after_ship_time = GNDcost[ship_to][next_pos];
                    if (get_ship_time==INT_MAX || shipping_time==INT_MAX || after_ship_time==INT_MAX)
                        continue;
                    dp[p+1][ship_to] = min(dp[p+1][ship_to],
                            dp[p][ship_from] + get_ship_time + shipping_time + after_ship_time);
                    if (dp[p][ship_from] + get_ship_time + shipping_time + after_ship_time < 0) {
                        cout << "overflowed " << p+1 spc ship_to << endl;
                        return 118;
                    }
                }

//                if (SEAcost[z[1]][ship_to] != INT_MAX && GNDcost[z[1]][ship_to] != INT_MAX)
//                    dp[1][ship_to] = SEAcost[z[1]][ship_to] + GNDcost[z[1]][ship_to];
            }
        }


//        REP(ship, 1, n+1) {
//            REP(p, 1, R+1) {
//                cout << std::setw(10) << dp[p][ship] << " ";
//            } cout << endl;
//        }

        int ans = INT_MAX;
        REP(i, 1, n+1) {
            ans = min(ans, dp[R][i]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 4972