#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int sea[200][200], land[200][200], z[1000];
ll dp[1000][200];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, R, x, y, t;
    char _c;
    while(cin >> N >> M && N){
        rep(i, N) rep(j, N)
          sea[i][j] = land[i][j] = i == j ? 0: INF;
        rep(i, M){
            cin >> x >> y >> t >> _c; --x; --y;
            if(_c == 'L')
              land[x][y] = land[y][x] = min(land[x][y], t);
            else
              sea[x][y] = sea[y][x] = min(sea[x][y], t);
        }
        cin >> R;
        rep(i, R){
            cin >> z[i];
            --z[i];
        }
        
        rep(k, N) rep(i, N) rep(j, N){
            sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);
            land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
        }
        
        rep(i, 1000) rep(j, 200) dp[i][j] = INF;
        dp[0][z[0]] = 0;
        REP(i, 1, R) rep(j, N){
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + (ll)land[z[i - 1]][z[i]]);
            rep(k, N)
              dp[i][k] = min(dp[i][k], dp[i - 1][j] + (ll)land[z[i - 1]][j] + (ll)sea[j][k] + (ll)land[k][z[i]]);
        }
        
        ll ans = INF;
        rep(i, N) ans = min(ans, dp[R - 1][i]);
        cout << ans << endl;
    }
    return 0;
}