cho.sh
Notes
Loading...

Distance Conditions for Four Points

Time limit

2s

Memory limit

128 MB

Problem

A 4 by 4 matrix gives the distances between four points. Determine whether four distinct points can be placed in three-dimensional Euclidean space so that all of the given distances hold at the same time.

Input

The input consists of 4 lines. Each line contains 4 integers. The j-th integer on the i-th line is the distance between point i and point j.

The i-th integer on the i-th line is always 0, and the j-th integer on the i-th line equals the i-th integer on the j-th line. When i and j are different, the value is a positive integer no greater than 10.

Output

Print YES if the given distances can describe four points, and print NO otherwise.

Hint

If every pairwise distance is 1, the four points can be placed at the vertices of a regular tetrahedron.