#include <bits/stdc++.h>
#define inf (int)1e8
using namespace std;

int n, m, r;
int dis[205][205][2] = {0}, dp[1005][205];
vector<int> z;

int solve();

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    for(int t = 0; t < 2; ++t)
      for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j) dis[i][j][t] = inf;
    for(int t = 0; t < 2; ++t)
      for(int i = 0; i < n; ++i) dis[i][i][t] = 0;
    for(int i = 0; i < m; ++i) {
      int x, y, t;
      string s;
      cin >> x >> y >> t >> s;
      --x, --y;
      dis[x][y][s == "L"] = min(dis[x][y][s == "L"], t);
      dis[y][x][s == "L"] = min(dis[y][x][s == "L"], t);
    }
    cin >> r;
    z.resize(r);
    for(int i = 0; i < r; ++i) {
      cin >> z[i];
      --z[i];
    }
    cout << solve() << endl;
  }
  return 0;
}

int solve() {
  if(r == 1) return 0;
  int ans = inf;
  // WF
  for(int t = 0; t < 2; ++t)
    for(int k = 0; k < n; ++k)
      for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
          dis[i][j][t] = min(dis[i][j][t],
                             dis[i][k][t] + dis[k][j][t]);
  for(int i = 0; i < r; ++i)
    for(int j = 0; j < n; ++j) dp[i][j] = inf;
  for(int i = 0; i < n; ++i) dp[0][i] = dis[z[0]][i][0];
  for(int i = 1; i < r; ++i)
    for(int j = 0; j < n; ++j) {
      dp[i][j] = min(dp[i][j],
                     dp[i - 1][j] + dis[z[i - 1]][z[i]][1]);
      for(int k = 0; k < n; ++k) {
        dp[i][j] = min(dp[i][j],
                       dp[i - 1][k] + dis[z[i - 1]][k][1] +
                           dis[k][j][0] + dis[j][z[i]][1]);
        if(i == r - 1) ans = min(ans, dp[i][j]);
      }
    }
  return ans;
}
