n,m,k=map(int,input().split()) r=[-1]*(1<0: sc,sp,sy=heappop(q) if sc>v[sp][sy]: continue for i,ty,tc in e[sy]: if r[i]!=-1: tp=sp|(1<sc+tc: v[tp][ty]=sc+tc heappush(q,(v[tp][ty],tp,ty)) print(v[-1][-1])