#K88932. Iceberg Collision Detection

    ID: 37418 Type: Default 1000ms 256MiB

Iceberg Collision Detection

Iceberg Collision Detection

Your task is to determine whether a ship is in danger of colliding with any icebergs. The ship is located at a given coordinate \((x_s,y_s)\). There are \(n\) icebergs, each located at coordinates \((x_i,y_i)\). An iceberg is considered a collision risk if the Euclidean distance between the ship and the iceberg is less than or equal to a specified threshold \(d\), i.e., if \(\sqrt{(x_i-x_s)^2+(y_i-y_s)^2} \le d\). If any iceberg meets this condition, output "Collision"; otherwise, output "Safe".

Input format: The first line contains three numbers: the ship's x-coordinate, the ship's y-coordinate, and the number of icebergs \(n\). The next \(n\) lines each contain two numbers representing the coordinates of an iceberg. The final line contains the collision distance threshold \(d\).

Note: All calculations using the Euclidean distance should consider the threshold \(d\) as the inclusive limit.

inputFormat

The input is read from stdin and consists of:

  • The first line: three space-separated numbers: xs ys n, where \(xs\) and \(ys\) are the ship's coordinates and \(n\) is the number of icebergs.
  • The following \(n\) lines: each line contains two space-separated numbers representing the coordinates of an iceberg.
  • The last line: a number d, the collision threshold.

outputFormat

Output a single line to stdout that contains either "Collision" if the ship is in danger, or "Safe" if not.

## sample
5 5 3
1 1
6 5
10 10
2
Collision