import sys
import numpy as np
import scipy.sparse as ss
f=ss.csgraph.floyd_warshall
def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(ss.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]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist()))
main() import sys sys import numpy as np numpy import scipy.sparse as ss scipy.sparse f=ss.csgraph.floyd_warshall f ss.csgraph.floyd_warshall ss.csgraph ss csgraph floyd_warshall def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(ss.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]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist())) main t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ') t np.fromstring(sys.stdin.buffer.read(),int,sep=' ') np.fromstring np fromstring sys.stdin.buffer.read() sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read int sep=' ' sep ' ' n,m,l=t[:3] n t[:3] t :3 3 m l m=m*3+3 m m*3+3 m*3 m 3 3 d=f(f(ss.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]] d f(f(ss.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]] (f(ss.csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l) f f(ss.csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l f(ss.csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0) f ss.csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2) ss.csr_matrix ss csr_matrix (t[5:m:3],(t[3:m:3],t[4:m:3])) t[5:m:3] t 5:m:3 5 m 3 (t[3:m:3],t[4:m:3]) t[3:m:3] t 3:m:3 3 m 3 t[4:m:3] t 4:m:3 4 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 d[d>n]=0 d[d>n] d d>n d n 0 print('\n'.join((d.astype(int)-1).astype(str).tolist())) print '\n'.join((d.astype(int)-1).astype(str).tolist()) '\n'.join '\n' join (d.astype(int)-1).astype(str).tolist() d.astype(int)-1).astype(str).tolist d.astype(int)-1).astype(str) d.astype(int)-1).astype d.astype(int)-1 d.astype(int) d.astype d astype int 1 astype str tolist main() main def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(ss.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]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist())) def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(ss.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]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist())) main f=ss.csgraph.floyd_warshall ss.csgraph.floyd_warshall f
import sys
import numpy as np
import scipy.sparse as ss
f=ss.csgraph.floyd_warshall
def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(ss.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]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist()))
main()