#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 10000000000LL
using namespace std;
typedef long long ll;

int N, M, R, X, Y, T, Z[1000];
char SL;
ll d[2][200][200];
ll dp[1000][200];

int main(void) {
  while(cin >> N >> M, N || M) {
    REP(w, 0, 2) REP(i, 0, N) REP(j, 0, N) d[w][i][j] = (i == j ? 0 : INF);
    REP(i, 0, M) {
      cin >> X >> Y >> T >> SL;
      d[SL == 'L'][X - 1][Y - 1] = T;
      d[SL == 'L'][Y - 1][X - 1] = T;
    }

    REP(w, 0, 2) REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) {
      d[w][i][j] = min(d[w][i][j], d[w][i][k] + d[w][k][j]);
    }

    cin >> R;
    REP(i, 0, R) cin >> Z[i], Z[i]--;

    REP(i, 0, R) REP(j, 0, N) dp[i][j] = INF;
    dp[0][Z[0]] = 0;

    REP(i, 1, R) {
      REP(j, 0, N) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + d[1][Z[i - 1]][Z[i]]);
      }
      REP(j, 0, N) REP(k, 0, N) {
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + d[1][Z[i - 1]][j] + d[0][j][k] + d[1][k][Z[i]]);
      }
    }

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

  return 0;
}