#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<28;
const double PI = acos(-1);
const double EPS = 1e-8;

int g1[200][200];
int g2[200][200];
int dist[2][200];
int z[1000];
int main() {
  int n, m;
  while(scanf("%d%d",&n,&m),n||m) {
    REP(i,n)REP(j,n)g1[i][j]=g2[i][j]=INF;
    REP(i,n)g1[i][i]=g2[i][i]=0;
    REP(i,m) {
      int a,b,c;
      char t;
      scanf("%d%d%d %c ",&a,&b,&c,&t);
      a--;b--;
      if (t=='L') g1[b][a]=g1[a][b]=min(g1[a][b],c);
      else g2[b][a]=g2[a][b]=min(g2[a][b],c);
    }
    REP(k,n)REP(i,n)REP(j,n)g1[i][j]=min(g1[i][j],g1[i][k]+g1[k][j]),g2[i][j]=min(g2[i][j],g2[i][k]+g2[k][j]);
    int r;scanf("%d",&r);
    REP(i,r) {
      scanf("%d",z+i);
      z[i]--;
    }
    REP(i,n)dist[0][i] = INF;
    dist[0][z[0]] = 0;
    int p;
    REP(i,r-1) {
      int *now = dist[i&1];
      int *nxt = dist[(i+1)&1];
      REP(j,n)nxt[j]=INF;
      REP(j,n)REP(k,n) {
        if (j==k) nxt[k]=min(nxt[k],now[j]+g1[z[i]][z[i+1]]);
        else nxt[k] = min(nxt[k], now[j]+g1[z[i]][j]+g2[j][k]+g1[k][z[i+1]]);
      }
      //REP(i,n) cout << nxt[i] << " ";cout<<endl;
    }
    int ans = INF;
    REP(i,n) ans=min(ans, dist[(r-1)&1][i]);
    printf("%d\n",ans);
  }
}