/*
  dp[テ」ツ?ゥテ」ツ?禿」ツ?セテ」ツ?ァテゥツ崢?ゥツ?催」ツ?療」ツ?淌」ツ?犠[ティツ按ケテ」ツ?ョテ・ツ?エテヲツ可?テ」ツ?ァDPテ」ツ??
  z[i] -> z[i+1]テ」ツ?ョテァツァツサテ・ツ仰陛」ツ?ョテゥツ堋崚」ツ?ォティツ按ケテ」ツ?ッテ・ツ、ツ堙」ツ?湘」ツ?ヲテ」ツつ?テ・ツ崢榲」ツ?療」ツ?凝、ツケツ療」ツつ嘉」ツ?ェテ」ツ??」ツ?ョテ」ツ?古」ツδ敕」ツつ、テ」ツδウテ」ツδ暗」ツ??」ツ?ィテヲツ?敕」ツ??」ツ??
 */
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 202;
const int MAXR = 1002;
const int INF = 1<<28;

int N, M;
int land[MAXN][MAXN], sea[MAXN][MAXN];
int R;
int Z[MAXR];

int dp[MAXR][MAXN];

void warshallFloyd(int n, int g[MAXN][MAXN]) {
  for(int k = 0; k < n; ++k) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

int main() {
  while(cin >> N >> M && (N|M)) {
    for(int i = 0; i < MAXN; ++i) {
      for(int j = 0; j < MAXN; ++j) {
        land[i][j] = sea[i][j] = (i == j) ? 0 : INF;
      }
    }
    for(int i = 0; i < M; ++i) {
      int x, y, t;
      char sl;
      cin >> x >> y >> t >> sl;
      --x; --y;
      if(sl == '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;
    for(int i = 0; i < R; ++i) {
      cin >> Z[i];
      --Z[i];
    }

    warshallFloyd(N, land);
    warshallFloyd(N, sea);

    fill(dp[0], dp[MAXR], INF);
    dp[0][Z[0]] = 0;
    for(int i = 0; i+1 < R; ++i) {
      for(int j = 0; j < N; ++j) {
        if(dp[i][j] == INF) continue;
        int a = Z[i];
        int b = Z[i+1];
        dp[i+1][j] = min(dp[i+1][j], dp[i][j] + land[a][b]);
        for(int k = 0; k < N; ++k) {
          dp[i+1][k] = min(dp[i+1][k],
                           dp[i][j] + land[a][j] + sea[j][k] + land[k][b]);
        }
      }
    }

    int res = INF;
    for(int j = 0; j < N; ++j) {
      res = min(res, dp[R-1][j]);
    }
    cout << res << endl;
  }
  return 0;
}