\problemname{Avoiding Airports}

\illustration{0.2}{avoidingairports/problem_statement/avoidingairports.png}


David is looking to book some travel over the world.
There are $n$ countries that he can visit,
and $m$ flights that are available.
The $i$th flight goes from country $a_i$ to country $b_i$.
It departs at time $s_i$, and lands at time $e_i$.

David is currently at the airport in country $1$, and the current time is $0$,
and he would like to travel country $n$.
He does not care about the total amount of time needed to travel,
but he really hates waiting in the airport.
If he waits $t$ seconds in an airport, he gains $t^2$ units of frustration.
Help him find an itinerary that minimizes the sum of frustration.

\section*{Input}

The first line of input contains two space-separated integers $n$
and $m$ ($1 \le n,m \le 200\,000$).

Each of the next $m$ lines contains four space-separated integers
$a_i$, $b_i$, $s_i$, and $e_i$
($1 \le a_i, b_i \le n$; $0 \le s_i \le e_i \le 10^6$).

A flight might have the same departure and arrival country.

No two flights will have the same arrival time, or have the same departure time.
In addition, no flight will have the same arrival time as the
departure time of another flight.
Finally, it is guaranteed that there will always be a way for David
to arrive at his destination.

\section*{Output}

Print, on a single line, the minimum sum of frustration.

~

\textit{Time limit}: solutions should complete in no more than $5$ CPU
seconds.

\section*{Examples}

In the first sample, it is optimal to take this sequence of flights:
\begin{itemize}
\item Flight $5$. Goes from airport $1$ to airport $2$, departing at time $3$, arriving at time $8$.
\item Flight $3$. Goes from airport $2$ to airport $1$, departing at time $9$, arriving at time $12$.
\item Flight $7$. Goes from airport $1$ to airport $3$, departing at time $13$, arriving at time $27$.
\item Flight $8$. Goes from airport $3$ to airport $5$, deparing at time $28$, arriving at time $100$.
\end{itemize}
The frustration for each flight is $3^2, 1^2, 1^2,$ and  $1^2$, respectively.
Thus, the total frustration is $12$.

Note that there is an itinerary that gets David to his destination
faster. However, that itinerary has a higher total frustration.
