from scipy.sparse import*

f=csgraph.johnson

t=list(map(int,open('/dev/fd/0').read().split()))

n,m,l=t[:3]

m=m*3+3

for i in f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1:print(i)
from scipy.sparse import*

f=csgraph.floyd_warshall

t=list(map(int,open('/dev/fd/0').read().split()))

n,m,l=t[:3]

m=m*3+3

for i in f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1:print(i)
from scipy.sparse import *

f = csgraph.johnson
t = list(map(int, open("/dev/fd/0").read().split()))
n, m, l = t[:3]
m = m * 3 + 3
for i in (
    f(f(csr_matrix((t[5:m:3], (t[3:m:3], t[4:m:3])), [n + 1] * 2), 0) <= l)[
        t[m + 1 :: 2], t[m + 2 :: 2]
    ].clip(0, n)
    % n
    - 1
):
    print(i)

from scipy.sparse import *

f = csgraph.floyd_warshall
t = list(map(int, open("/dev/fd/0").read().split()))
n, m, l = t[:3]
m = m * 3 + 3
for i in (
    f(f(csr_matrix((t[5:m:3], (t[3:m:3], t[4:m:3])), [n + 1] * 2), 0) <= l)[
        t[m + 1 :: 2], t[m + 2 :: 2]
    ].clip(0, n)
    % n
    - 1
):
    print(i)

-f = csgraph.johnson +f = csgraph.floyd_warshall