N,M = list(map(int,input().split()))

src = [tuple(map(int,input().split())) for i in range(M)]

INF = float('inf')

wf = [[INF]*N for i in range(N)]

for a,b,c in src:

    a,b = a-1,b-1

    wf[a][b] = wf[b][a] = c

for i in range(N):

    wf[i][i] = 0



for k in range(N):

    for i in range(N):

        for j in range(N):

            wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j])



ans = 0

for a,b,c in src:

    a,b = a-1,b-1

    if c != wf[a][b]:

        ans += 1

print(ans)
N,M = list(map(int,input().split()))

ABC = [tuple(map(int,input().split())) for i in range(M)]



INF = float('inf')

ds = [[INF]*N for _ in range(N)]

for i in range(N):

    ds[i][i] = 0

for a,b,c in ABC:

    a,b = a-1,b-1

    ds[a][b] = ds[b][a] = c



for k in range(N):

    for i in range(N):

        for j in range(N):

            ds[i][j] = min(ds[i][j], ds[i][k]+ds[k][j])



ans = 0

for a,b,c in ABC:

    a,b = a-1,b-1

    if ds[a][b] < c:

        ans += 1

print(ans)
N, M = list(map(int, input().split()))
src = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
wf = [[INF] * N for i in range(N)]
for a, b, c in src:
    a, b = a - 1, b - 1
    wf[a][b] = wf[b][a] = c
for i in range(N):
    wf[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j])
ans = 0
for a, b, c in src:
    a, b = a - 1, b - 1
    if c != wf[a][b]:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
ABC = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
ds = [[INF] * N for _ in range(N)]
for i in range(N):
    ds[i][i] = 0
for a, b, c in ABC:
    a, b = a - 1, b - 1
    ds[a][b] = ds[b][a] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j])
ans = 0
for a, b, c in ABC:
    a, b = a - 1, b - 1
    if ds[a][b] < c:
        ans += 1
print(ans)

-src = [tuple(map(int, input().split())) for i in range(M)] +ABC = [tuple(map(int, input().split())) for i in range(M)] -wf = [[INF] * N for i in range(N)] -for a, b, c in src: +ds = [[INF] * N for _ in range(N)] +for i in range(N): +    ds[i][i] = 0 +for a, b, c in ABC: -    wf[a][b] = wf[b][a] = c -for i in range(N): -    wf[i][i] = 0 +    ds[a][b] = ds[b][a] = c -            wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]) +            ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]) -for a, b, c in src: +for a, b, c in ABC: -    if c != wf[a][b]: +    if ds[a][b] < c: