from scipy.sparse import*
f=csgraph.johnson
n,m,l,*t=map(int,open(0).read().split())
m*=3
[*map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1)] from scipy.sparse import* f=csgraph.johnson f csgraph.johnson csgraph johnson n,m,l,*t=map(int,open(0).read().split()) n map(int,open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split m l *t t m*=3 m 3 [*map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1)] *map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1) map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1) map print f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1 f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n) [t[m+1::2],t[m+2::2]].clip [t[m+1::2],t[m+2::2]] (f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l) f f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0) f csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2) csr_matrix (t[2:m:3],(t[:m:3],t[1:m:3])) t[2:m:3] t 2:m:3 2 m 3 (t[:m:3],t[1:m:3]) t[:m:3] t :m:3 m 3 t[1:m:3] t 1:m:3 1 m 3 [n+1]*2 [n+1] n+1 n 1 2 0 l t[m+1::2] t m+1::2 m+1 m 1 2 clip 0 n n 1 f=csgraph.johnson csgraph.johnson f m,l,*t=map(int,open(0).read().split()) map(int,open(0).read().split()) m n,m,l,*t=map(int,open(0).read().split()) map(int,open(0).read().split()) n l,*t=map(int,open(0).read().split()) map(int,open(0).read().split()) l m*=3 3 m
from scipy.sparse import*
f=csgraph.johnson
n,m,l,*t=map(int,open(0).read().split())
m*=3
[*map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1)]