/*
AOJ 2200 Mr. Rito Post Office

????????°???????????????????????????ACM-ICPC Japan??????????????????????¨?????????????????????????
?????????????\?????????????????????°??????????????¨?????????????????????????°´????????±??????????????°?°´
??????????????¨????????¨X????????????????°±?????¨X????????????????????????????????????????¬??????°?°´???
??????????????°X?????????????????????????????´?????????????????\???????°´????????±?????????????????????
?????§???????????????????????????????????????????????????????????¶?????????????????????????????????????¬?
??§???????????????ABCB??????B????????????????????°????¬?????????????

????????°???????????????
N M
x1 y1 t1 sl1
x2 y2 t2 sl2
???
xM yM tM slM
R
z1 z2 ??? zR

N (2 ??? N ??? 200) ??????????????°??????M (1 ??? M ??? 10000) ?????±???????°´????????????
??°??????????¬¬2?????°?¬¬M + 1????????????????????°??????????????\xi yi?????°???????????±?´? ti
(1 ??? ti ??? 1000)??¶??´???sli ???L??¶??¨????????±??????S??¶??¨???????°´?????????????????????
?????\??????????????\?????????????????¶???????????????????????????

M + 2??????R????????????????????????????????°??????M + 3???????????????????????????????????????

????§???¶????????????????????¨?¬¬??????????????????????????????????????°?????????????????????

????????°??????0 0?????¶?????¨????????¢???

 */
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }
const int INF = 0x1F1F1F1F;

const int N = 200;

int distL[N][N], distS[N][N];
int dp[2][N];
int n, m;

int main(int argc, char *argv[]) {
  int x, y, t;
  char sl;
  while (scanf("%d %d", &n, &m) == 2 && n + m > 0) {
    CLR(distL, INF);
    CLR(distS, INF);
    REP(i, n) distL[i][i] = distS[i][i] = 0;
    while (m--) {
      scanf("%d %d %d %c", &x, &y, &t, &sl);
      --x;
      --y;
      switch (sl) {
        case 'L':
          checkmin(distL[x][y], t);
          checkmin(distL[y][x], t);
          break;
        case 'S':
          checkmin(distS[x][y], t);
          checkmin(distS[y][x], t);
          break;
      }
    }
    REP(k, n) REP(i, n) REP(j, n) {
      checkmin(distL[i][j], distL[i][k] + distL[k][j]);
      checkmin(distS[i][j], distS[i][k] + distS[k][j]);
    }
    int current = 0, prev = 1, src=0, dst=0;
    CLR(dp, INF);
    scanf("%d", &m);
    scanf("%d", &dst);
    dp[current][--dst] = 0;
    while (--m) {
      src = dst;
      scanf("%d", &dst);
      --dst;
      swap(current, prev);
      CLR(dp[current], INF);
      REP(i, n) {
	if (dp[prev][i] == INF) continue;
	if (distL[src][dst] != INF)
	  checkmin(dp[current][i], dp[prev][i] + distL[src][dst]);
	if (distL[src][i] == INF) continue;
	REP(j, n) {
	  if (distL[src][i] != INF && distS[i][j] != INF && distL[j][dst] != INF) {
	    checkmin(dp[current][j], dp[prev][i] + distL[src][i] + distS[i][j] + distL[j][dst]);
	  }
	}
      }
      //cerr << "NEXT=" << dst + 1 << " ";
      //int bestIdx = min_element(dp[current], dp[current] + n) - dp[current];
      //cerr << " BEST=" << bestIdx + 1 << " VAL=" << dp[current][bestIdx] << endl;
    }
    printf("%d\n", *min_element(dp[current], dp[current] + n));
  }
}

Measured memory_bytes: 1508