from queue import PriorityQueue
n, m = map(int, input().split())
edges = [[] for i in range(n)]
for i in range(m):
u, v, l, c, d = map(int, input().split())
u -= 1
v -= 1
if l > d:
continue
edges[u].append((v, c, d, l))
edges[v].append((u, c, d, l))
INF = int(1e9)
D = [INF for i in range(n)]
D[0] = 0
pq = PriorityQueue()
pq.put((0, 0))
while not pq.empty():
(dist, v) = pq.get()
if D[v] != dist:
continue
for i in range(len(edges[v])):
(to, c, d, l) = edges[v][i]
t = D[v] % (c + d)
if t < c:
new_D = D[v] - t + c + l
else:
if t + l <= c + d:
new_D = D[v] + l
else:
new_D = D[v] - t + c + l + (c + d)
if D[to] > new_D:
D[to] = new_D
pq.put((D[to], to))
if D[n - 1] == INF:
print("Try again the next day!")
else:
print(D[n - 1])