Rain#396

Rain

1 second
64 megabytes
Very easy

\includegraphics{https://static.e-olymp.com/content/08/08a75116cc0629e35995fdfab7d89a18c2c10622.jpg}

A raindrop falls straight down from a significant height to the ground. During its descent, it may encounter obstacles that change its path.

We will examine a two-dimensional version of this scenario on a plane. The obstacles are inclined line segments that do not intersect, and the raindrop is considered to be a point. The drop falls vertically from a point above all obstacles. If it touches a segment while falling, it slides along the segment until it reaches the lower end, from where it continues to fall vertically.

Write a program to calculate the coordinate where the drop ultimately lands on the ground ( = ).

Input

The input begins with two integers separated by a space on the first line: the coordinate X_0 of the drop's starting point (0 < X_0 < 10000) and the number of segment-obstacles (0 \leq N \leq 100). This is followed by lines, each containing four space-separated integers x_1, y_1, x_2, y_2 — the coordinates of the left and right endpoints of each segment-obstacle (all numbers are integers ranging from to , x_1 < x_2, y_1 \neq y_2). The segments do not intersect or touch each other.

Output

Output a single integer: the coordinate where the drop lands on the ground.

Examples

Example 1

Loading
Loading