#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 150000;
const int MAX_M = 300000;
vector<pair<int, int>> g[MAX_N];
int l[MAX_M], c[MAX_M], d[MAX_M];
int D[MAX_N];
int main()
{
int n, m;
cin >> n >> m;
for(int i = 0; i < m; i++){
int u, v;
cin >> u >> v >> l[i] >> c[i] >> d[i];
u--; v--;
g[u].push_back({v, i});
g[v].push_back({u, i});
}
for(int i = 0; i < n; i++){
D[i] = 1000'000'000;
}
D[0] = 0;
set<pair<int, int>> q;
q.insert({D[0], 0});
while(!q.empty()){
int v = q.begin()->second;
q.erase(q.begin());
for(auto [to, e] : g[v]){
if(d[e] < l[e])
continue;
int new_D;
int t = D[v] % (d[e] + c[e]);
if(t < c[e]){
new_D = D[v] - t + c[e] + l[e];
}
else{
if(t + l[e] <= c[e] + d[e]){
new_D = D[v] + l[e];
}
else{
new_D = D[v] - t + c[e] + l[e] + (c[e] + d[e]);
}
}
if(D[to] > new_D){
q.erase({D[to], to});
D[to] = new_D;
q.insert({D[to], to});
}
}
}
if(D[n - 1] != 1000'000'000){
cout << D[n - 1] << endl;
}
else{
cout << "Try again the next day!" << endl;
}
return 0;
}