// Author: Christoph Schwirzer
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;
int a[128][128];
const int oo = 1000000000;
int main()
{
//	freopen("hotel.in", "r", stdin);
	int n;
	while (scanf("%d", &n), n)
	{
		int h;
		scanf("%d", &h);
		VI hotel(n);
		hotel[0] = 1;
		hotel[n-1] = 1;
		for (int i=0; i<h; i++)
		{
			int x;
			scanf("%d", &x);
			hotel[x-1] = 1;
		}
		int m;
		scanf("%d", &m);
		VVPII adj(n);
		for (int i=0; i<m; i++)
		{
			int x, y, t;
			scanf("%d%d%d", &x, &y, &t);
			adj[x-1].push_back(PII(y-1, t));
			adj[y-1].push_back(PII(x-1, t));
		}
		int k = count(hotel.begin(), hotel.end(), 1);
		for (int i=0; i<k; i++)
			for (int j=0; j<k; j++)
				a[i][j] = oo;
		for (int i=0, x=0; i<n; i++)
			if (hotel[i])
			{
				priority_queue<PII, vector<PII>, greater<PII> > pq;
				pq.push(PII(0, i));
				VI dist(n, 601);
				dist[i] = 0;
				while (!pq.empty())
				{
					PII act = pq.top();
					pq.pop();
					if (act.first != dist[act.second])
					{
						continue;
					}
					for (VPII::iterator it = adj[act.second].begin(); it != adj[act.second].end(); ++it)
					{
						int t = act.first + it->second;
						if (t < dist[it->first])
						{
							dist[it->first] = t;
							pq.push(PII(t, it->first));
						}
					}
				}
				for (int j=0, y=0; j<n; j++)
					if (hotel[j])
					{
						if (dist[j] <= 600)
							a[x][y] = 1;
						y++;
					}
				x++;
			}
		for (int z=0; z<k; z++)
			for (int i=0; i<k; i++)
				for (int j=0; j<k; j++)
					a[i][j] = min(a[i][z] + a[z][j], a[i][j]);
		if (a[0][k-1] == oo)
			cout << -1 << endl;
		else
			cout << a[0][k-1] - 1 << endl;
	}
	return 0;
}
