#include<iostream>
#include<cstdio>
#include<vector>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int land[202][202];
int sea[202][202];

const int inf = INT_MAX / 4;

int main() {
  for(int N, M; cin >> N >> M, (N || M); ) {
    REP(i, N) REP(j, N) land[i][j] = inf;
    REP(i, N) REP(j, N) sea[i][j] = inf;

    REP(i, M) {
      int a, b, c;
      char ch;
      scanf("%d%d%d %c", &a, &b, &c, &ch);
      a--, b--;
      if( ch == 'L' )
        land[a][b] = land[b][a] = c;
      else
        sea[a][b] = sea[b][a] = c;
    }

    int R;
    static int Z[1024];
    scanf("%d", &R);
    REP(r, R) scanf("%d", &Z[r]);
    REP(r, R) Z[r]--;

    REP(i, N) land[i][i] = sea[i][i] = 0;
    REP(k, N) REP(i, N) REP(j, N) land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
    REP(k, N) REP(i, N) REP(j, N) sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);

    static int dp[202][1024];
    REP(i, 202) REP(j, 1024) dp[i][j] = inf;
    dp[Z[0]][0] = 0;
    REP(r, R - 1) REP(ship, N) {
      int next = dp[ship][r + 1];
      next = min(next, dp[ship][r] + land[Z[r]][Z[r + 1]]);
      REP(mship, N)
        next = min(next, dp[mship][r] + land[Z[r]][mship] + sea[mship][ship] + land[ship][Z[r + 1]]);
      dp[ship][r+1] = next;
    }

    int best = inf;
    REP(ship, N)
      best = min(best, dp[ship][R - 1]);
    cout << best << endl;
  }
  return 0;
}