#!/usr/bin/env python3
import string
import heapq
from collections import defaultdict

INF = 1 << 30


s,p,t = map(int, input().split())

packing = set(int(input()) for i in range(p))

f_dist = [[INF for __ in range(s + 1)] for _ in range(s + 1)]
lo_dist = [[INF for __ in range(s + 1)] for _ in range(s + 1)]
for i in range(s + 1):
    f_dist[i][i] = 0

f_graph = [[] for i in range(s + 1)]
up_trans = [{} for i in range(s + 1)]
b_graph = [defaultdict(list) for i in range(s + 1)]
for i in range(t):
    a,c,b = input().split()
    a = int(a)
    b = int(b)
    if a != b:
        f_dist[a][b] = 1

    if c.islower():
        lo_dist[a][b] = 1
    else:
        up_trans[a][c] = b
    f_graph[a].append((b, c))
    b_graph[b][c].append(a)

# compute all forward distances, and distances only using lower case letters
for __ in range(4):
    for k in range(s + 1):
        for i in range(s + 1):
            for j in range(s + 1):
                f_dist[i][j] = min(f_dist[i][j], f_dist[i][k] + f_dist[k][j])
                lo_dist[i][j] = min(lo_dist[i][j], lo_dist[i][k] + lo_dist[k][j])

# compute dist each state to a end state using only lowercase characters
cyc_dist = [INF for __ in range(s + 1)]
for i in range(s + 1):
    for p in packing:
        cyc_dist[i] = min(cyc_dist[i], lo_dist[i][p])

# compute min dist to get pair of states to end states, must match uppercase characters
b_dist = [[INF for __ in range(s + 1)] for _ in range(s + 1)]
q = []
def update(cost, i, j):
    if cost < b_dist[i][j]:
        b_dist[i][j] = cost
        heapq.heappush(q, (cost, i, j))

for i in range(s + 1):
    for j in range(s + 1):
        if i in packing and j in packing:
            update(0, i, j)

while len(q) > 0:
    cost,a,b = heapq.heappop(q)
    if b_dist[a][b] != cost:
        continue
    for c in string.ascii_uppercase:
        for na in b_graph[a][c]:
            for nb in b_graph[b][c]:
                update(b_dist[a][b] + 2, na, nb)

    for c in string.ascii_lowercase:
        for na in b_graph[a][c]:
            update(b_dist[a][b] + 1, na, b)
        for nb in b_graph[b][c]:
            update(b_dist[a][b] + 1, a, nb)

# compute best total cost
best_cost = INF
for split in range(1, s + 1):
    # fix point in string which they first differ
    if f_dist[1][split] < INF:
        cur_cost = f_dist[1][split] * 2
        # case one, these two things differ on a lowercase letter
        for a, ac in f_graph[split]:
            for b, bc in f_graph[split]:
                if ac.islower() and bc.islower() and ac != bc:
                    best_cost = min(best_cost, cur_cost + 2 + b_dist[a][b])
        # case two, one thing is a prefix of the other
        if split in packing:
            best_cost = min(best_cost, cur_cost + cyc_dist[split])
        # case three, these two things differ, one of them is an uppercase letter
        for ac, a in up_trans[split].items():
            # fix which one lower case leads to, then go to an uppercase letter
            for c in range(s + 1):
                if ac in up_trans[c]:
                    best_cost = min(best_cost, cur_cost + 1 + lo_dist[split][c] + 1 + b_dist[a][up_trans[c][ac]])


print(-1 if best_cost >= INF else best_cost)
