N,M = list(map(int,input().split()))

es = [tuple(map(int,input().split())) for i in range(M)]



INF = float('inf')

d = [INF] * N

d[0] = 0

for i in range(N):

    for fr,to,cost in es:

        fr,to = fr-1,to-1

        cost *= -1

        if d[fr] != INF and d[to] > d[fr]+cost:

            d[to] = d[fr] + cost

            if i == N-1 and to == N-1:

                print('inf')

                exit()

print((-d[-1]))
N,M = list(map(int,input().split()))

ABC = [tuple(map(int,input().split())) for i in range(M)]



INF = float('inf')

dist = [INF] * N

dist[0] = 0

for i in range(N):

    for a,b,c in ABC:

        a,b,c = a-1,b-1,-c

        if dist[b] > dist[a] + c:

            dist[b] = dist[a] + c

            if i==N-1 and b == N-1:

                print('inf')

                exit()

print((-dist[-1]))
N, M = list(map(int, input().split()))
es = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
d = [INF] * N
d[0] = 0
for i in range(N):
    for fr, to, cost in es:
        fr, to = fr - 1, to - 1
        cost *= -1
        if d[fr] != INF and d[to] > d[fr] + cost:
            d[to] = d[fr] + cost
            if i == N - 1 and to == N - 1:
                print("inf")
                exit()
print((-d[-1]))

N, M = list(map(int, input().split()))
ABC = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
dist = [INF] * N
dist[0] = 0
for i in range(N):
    for a, b, c in ABC:
        a, b, c = a - 1, b - 1, -c
        if dist[b] > dist[a] + c:
            dist[b] = dist[a] + c
            if i == N - 1 and b == N - 1:
                print("inf")
                exit()
print((-dist[-1]))

-es = [tuple(map(int, input().split())) for i in range(M)] +ABC = [tuple(map(int, input().split())) for i in range(M)] -d = [INF] * N -d[0] = 0 +dist = [INF] * N +dist[0] = 0 -    for fr, to, cost in es: -        fr, to = fr - 1, to - 1 -        cost *= -1 -        if d[fr] != INF and d[to] > d[fr] + cost: -            d[to] = d[fr] + cost -            if i == N - 1 and to == N - 1: +    for a, b, c in ABC: +        a, b, c = a - 1, b - 1, -c +        if dist[b] > dist[a] + c: +            dist[b] = dist[a] + c +            if i == N - 1 and b == N - 1: -print((-d[-1])) +print((-dist[-1]))