#include <bits/stdc++.h> // {{{

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) (std::cerr << #x << ':' << ' ' << x << '\n')
#define TMPL_T template <typename T>
#define TMPL_TU template <typename T, typename U>
#define mut auto
#define let const auto

using Int = long long;
// clang-format off
namespace extio {
std::string delimiter=" ",pdelimiter=" ";
std::string bracket_b="",bracket_e="";
void chdelim(const std::string&s){delimiter=s;}
void chpdelim(const std::string&s){pdelimiter=s;}
void chbracket(const std::string&b,const std::string&e){bracket_b=b,bracket_e=e;}
TMPL_T  void pcont(std::ostream&os,const T&x){int c=0;for(const auto&a:x){if(c++)os<<delimiter;os<<a;}}
TMPL_TU void ppair(std::ostream&os,const std::pair<T,U>&p){os<<bracket_b<<p.first<<pdelimiter<<p.second<<bracket_e;}
}
namespace std {
TMPL_T ostream& operator<<(ostream&os,const vector<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const set<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const multiset<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const deque<T>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const map<T,U>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const pair<T,U>&x){extio::ppair(os,x);return os;}
TMPL_T istream& operator>>(istream&is,tuple<int&,vector<T>&>x)
{int N=get<0>(x);vector<T>&v=get<1>(x);v.clear();v.reserve(N);REP(i,N){T a;is>>a;v.emplace_back(a);}return is;}
TMPL_T istream& operator>>(istream&is,tuple<vector<T>&,int&>x){return is>>tie(get<1>(x),get<0>(x));}
TMPL_T istream& operator>>(istream&is,tuple<int&,T*>x){int N=get<0>(x);T*v=get<1>(x);REP(i,N){is>>v[i];}return is;}
TMPL_T istream& operator>>(istream&is,tuple<T*,int&>x){return is>>tie(get<1>(x),get<0>(x));}
}
TMPL_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
TMPL_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}

inline int in(){int x;std::cin>>x;return x;}

struct Initializer_ {
  Initializer_(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::setprecision(10);
    std::cerr << std::setprecision(10);
  }
} precalc;
// clang-format on
// }}}

using namespace std;

signed main() {
  int N, M;
  while (N = in(), M = in(), N || M) {
    int min_cost[2][222][222];
    memset(min_cost, 0x1f, sizeof(min_cost));
    REP(i, N) { min_cost[0][i][i] = min_cost[1][i][i] = 0; }
    REP(i, M) {
      int x, y, t;
      string sl;
      cin >> x >> y >> t >> sl;
      x--, y--;
      int k = "L" == sl;
      chmin(min_cost[k][x][y], t);
      chmin(min_cost[k][y][x], t);
    }
    int R = in();
    vector<int> Z;
    cin >> tie(R, Z);
    for (auto&& z : Z) {
      z--;
    }
    REP(k, N) REP(i, N) REP(j, N) {
      chmin(min_cost[0][i][j], min_cost[0][i][k] + min_cost[0][k][j]);
      chmin(min_cost[1][i][j], min_cost[1][i][k] + min_cost[1][k][j]);
    }
    int dp[1010][222];
    memset(dp, 0x1f, sizeof(dp));
    dp[0][Z[0]] = 0;
    REP(i, R - 1) {
      int cur = Z[i], nxt = Z[i + 1];
      REP(j, N) {
        chmin(dp[i + 1][j], dp[i][j] + min_cost[1][cur][nxt]);
        REP(k, N) {
          chmin(dp[i + 1][k],
                dp[i][j] + min_cost[1][cur][j] + min_cost[0][j][k] + min_cost[1][k][nxt]);
        }
      }
    }
    cout << *min_element(dp[R - 1], dp[R]) << endl;
  }
  return 0;
}

Measured memory_bytes: 4400