import sys input = sys.stdin.readline from heapq import heappop,heappush N,M,C=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(M)] for i in range(M): EDGE[i][0]-=1 EDGE[i][1]-=1 P=[1<<63]*N P[0]=0 for i in range(N+10): for x,y,w in EDGE: if P[y]>P[x]-w: P[y]=P[x]-w Q=list(map(int,input().split())) for i in range(C): Q[i]-=1 USE=[1]*M for q in Q: USE[q]^=1 DP=[1<<63]*N DP[0]=0 E=[[] for i in range(N)] for i in range(M): if USE[i]==0: E[x].append((y,1<<63)) continue x,y,dis=EDGE[i] E[x].append((y,-dis)) Q=[(0,0)] while Q: now,ind=heappop(Q) if DP[ind]!=now: continue for to,w in E[ind]: if DP[to]>DP[ind]+w+P[ind]-P[to]: DP[to]=DP[ind]+w+P[ind]-P[to] heappush(Q,(DP[to],to)) ANS=DP[-1]+P[-1] if ANS>1000000000: print("NaN") else: print(-ANS)