7 3
1 4 7
1 2 2
2 3 3
3 4 8
2 5 1
1 6 4
6 7 5
 10 2
1 5
5 3 2
8 4 8
7 6 9
7 10 1
10 1 4
9 5 1
5 8 2
7 2 9
6 5 6
 10 5
4 8 7 5 1
5 1 1
2 7 1
4 3 1
10 9 1
10 1 1
1 8 1
10 7 1
10 3 1
7 6 1
 10 9
9 7 6 10 3 5 2 8 1
9 4 10
10 8 3
3 6 2
5 1 8
5 2 5
1 10 10
6 7 1
9 1 7
1 6 3
 10 5
8 5 2 10 1
3 1 7
5 4 6
10 8 4
6 8 9
7 8 4
9 5 6
8 1 9
2 10 2
9 8 7

3 2
 2 3
 5 1
 0 1
 5 1

from sys import stdin
from collections import deque

def make_matrix(n, m):
    return [[0] * m for i in xrange(n)]

def traverse_graph(G, start, goals):
    n = len(G)
    visited = set()
    path = []

    def dfs(v, dist):
        visited.add(v)
        path.append(v)
        if v in goals:
            yield dist, path
        for u in xrange(n):
            if G[v][u] > 0 and u not in visited:
                for pair in dfs(u, dist + G[u][v]):
                    yield pair
        path.pop()

    return dfs(start, 0)

def find_longest_paths(G, start, goals):
    longest = 0; longest_paths = []
    for dist, path in traverse_graph(G, start, goals):
        if dist > longest:
            longest = dist
            longest_paths = [set(path)]
        elif dist ==  longest:
            longest_paths.append(set(path))
    return longest_paths

n, m = map(int, stdin.readline().split())
monasteries = set(int(x) - 1 for x in stdin.readline().split())
G = make_matrix(n, n)
for line in stdin:
    a, b, c = [int(x) - 1 for x in line.split()]
    G[a][b] = G[b][a] = c + 1

destroyables = set(xrange(n)) - monasteries
unhappy = {}
for v in monasteries:
    paths = find_longest_paths(G, v, monasteries)
    for u in destroyables:
        remaining_paths = [pth for pth in paths if u not in pth]
        if not remaining_paths:
            unhappy[u] = unhappy.get(u, 0) + 1

L = unhappy.values()
unhappy_max = max(L) if L else 0
unhappy_ways = L.count(unhappy_max)

print unhappy_max, unhappy_ways