Collision Detection

Time limit1sMemory limit128 MB

Problem

As a preliminary step in building an autonomous-vehicle system, your team must show that a central traffic controller can raise an alert whenever two cars are likely to collide unless someone takes corrective action.

The test course is a set of straight tracks that cross one another at various angles. As a car passes a sensor mounted on a track, its position and speed are recorded and sent to the controller, which keeps the two most recent readings for each car.

The process carries some built-in uncertainty: the sensor readings are not exact, and the sensors cannot tell whether a driver is already aware of the other traffic. The controller can almost never prove that a collision is unavoidable, and even if it could, it would rarely do so in time for the drivers to react.

We therefore want the controller to raise an alert whenever two cars will pass dangerously close to each other at any moment during the next 30 seconds, assuming both keep behaving as they were most recently observed to behave. Two cars are dangerously close if they pass within 18 ft of each other, and safe if their closest approach is at least 20 ft. A closest approach between 18 ft and 20 ft is ambiguous and may be reported either way.

Assume that:

  • each car stays on its straight track;
  • the acceleration (change in speed per unit time) of each car stays constant over the interval between its two readings and for the next 30 seconds, except for the two cases listed below. Acceleration may be negative, meaning the car is slowing down.

If a car with initial speed $s_0$ has constant acceleration $a$, then after a time interval $t$ its speed is

$$s_t = a,t + s_0$$

and over that same interval it travels a distance

$$d = \frac{a}{2},t^2 + s_0,t.$$

The two exceptions to the constant-acceleration rule are:

  1. a decelerating car stops decelerating once its speed reaches $0$ (cars never go into reverse);
  2. an accelerating car stops accelerating once its speed reaches $80$ feet per second (about 55 mph).

Input

The input contains one or more data sets.

Each data set has 4 observations, one per line. The first two observations belong to car 1 and the last two belong to car 2. Each observation is four floating-point numbers $t$, $x$, $y$, $s$:

  • $t$ — the time of the observation in seconds, $0 \le t \le 120$;
  • $x$, $y$ — the car's position in feet, $-5000 \le x, y \le 5000$;
  • $s$ — the speed in feet per second, $0 \le s \le 80$.

No data set has a closest approach that falls in the ambiguous 18–20 ft range. For each car the two observations happen at distinct times, and the earlier observation is listed first.

The input ends with one observation made of 4 negative numbers, which is not part of any data set.

Output

For each data set, print one line — either Dangerous or Safe — according to whether a dangerously close passage is predicted within the 30 seconds following the largest of the 4 observation times.