// Author: Walter Guttmann
#include <fstream>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

//ifstream in("hotel.in");
#define in cin

typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;

const int infty = 1<<28;

int mat[128][128], rch[1<<14], dist[1<<14];
vvpi adj;

int main() {
  int n;
  while (in >> n) {
    if (n == 0) break;
    adj = vvpi(n+1);
    int h, ch[128];
    for (int i=0 ; i<=n ; i++)
      rch[i] = -1;
    in >> h;
    for (int i=0 ; i<h ; i++) {
      in >> ch[i];
      rch[ch[i]] = i;
    }
    if (rch[1] == -1) {
      ch[h] = 1;
      rch[1] = h;
      ++h;
    }
    if (rch[n] == -1) {
      ch[h] = n;
      rch[n] = h;
      ++h;
    }
    int m;
    in >> m;
    for (int i=0 ; i<m ; i++) {
      int from, to, len;
      in >> from >> to >> len;
      adj[from].push_back(pi(to, len));
      adj[to].push_back(pi(from, len));
    }
    for (int i=0 ; i<h ; i++)
      for (int j=0 ; j<h ; j++)
        mat[i][j] = i==j ? 0 : infty;
    for (int i=0 ; i<h ; i++) {
      for (int j=1 ; j<=n ; j++)
        dist[j] = infty;
      dist[ch[i]] = 0;
      priority_queue<pi> que;
      que.push(pi(0, ch[i]));
      while (!que.empty()) {
        int t = - que.top().first;
        int u = que.top().second;
        que.pop();
        if (rch[u] != -1 && u != ch[i])
          mat[i][rch[u]] = mat[rch[u]][i] = 1;
        for (unsigned int j=0 ; j<adj[u].size() ; j++) {
          int nt = t + adj[u][j].second;
          if (nt <= 600 && nt < dist[adj[u][j].first]) {
            dist[adj[u][j].first] = nt;
            que.push(pi(-nt, adj[u][j].first));
          }
        }
      }
    }
    for (int k=0 ; k<h ; k++)
      for (int i=0 ; i<h ; i++)
        for (int j=0 ; j<h ; j++)
          mat[i][j] = min(mat[i][j], min(mat[i][k] + mat[k][j], infty));
    if (mat[rch[1]][rch[n]] < infty)
      cout << mat[rch[1]][rch[n]]-1 << endl;
    else
      cout << "-1" << endl;
  }
  return 0;
}

